怎么通过查询来获取点的坐标

0 投票
263 浏览
iserver 做数据查询时,我通过 name 查询出来了一个点,怎么获得这个点的坐标,然后把它标记出来呢

这是我的部分代码,该怎么写呢

getFeatureParam = new SuperMap.REST.FilterParameter({
            name: "公交站点@XY",
            attributeFilter: "NAME='"+zhandian+"'",  
            fields:['SmX','SmY']        
        });
        
        getFeatureBySQLParams = new SuperMap.REST.GetFeaturesBySQLParameters({
            queryParameter: getFeatureParam,
            datasetNames: ["XY:公交站点"]
        });
        //查询成功,执行 processCompleted 失败,执行 processFailed
        getFeatureBySQLService = new SuperMap.REST.GetFeaturesBySQLService(url2, {
            eventListeners: {"processCompleted": processCompleted, "processFailed": processFailed}
        });

        getFeatureBySQLService.processAsync(getFeatureBySQLParams);
    }

//在地图上显示
    function processCompleted(getFeaturesEventArgs) {
        var size = new SuperMap.Size(21, 21);
        var offset = new SuperMap.Pixel(-(size.w / 2), -size.h);
        var icon = new SuperMap.Icon('./images/marker.png', size, offset);
        var i, len, features, feature, result = getFeaturesEventArgs.result;
        if (result && result.features) {
            features = result.features
            
            for (i = 0, len = features.length; i < len; i++) {
                feature = features[i];
                //alert(feature.LonLat{lat});
                //markerlayer.addMarker(new SuperMap.Marker(new SuperMap.LonLat(feature.LonLat.lon,feature.LonLat.lat), icon));
                 //map.setCenter(new SuperMap.LonLat(feature.LonLat{lat},feature.LonLat{lon}), 5);
                 feature.style = style;
                 markerlayer.addFeatures(feature);
            }
        }
    }
最新提问 6月 28 分类:  263次浏览 | 用户: 617 (0 分)

1个回答

0 投票

您好,你console.log(features);看下就知道了,坐标存储在features.geometry下边。

最新回答 6月 29 用户: 李熙y 名扬四海 (4,380 分)
请问存储在features.geometry下边,然后怎么获得它呀,写成什么样的形式呢,我试了一下,不知道怎么写出来

features.geometry.x,features.geometry.y这种

...