iclient-classic地图SQL查询,怎样让查询结果居中放大显示

0 投票
小白一个,最近用iclient classic编程遇到了很多问题。怎样让地图SQL查询结果居中放大显示呀?
11月 6, 2019 分类:  110次浏览 | 用户: weixixi 初出茅庐 (20 分)
重新分类 11月 6, 2019 用户:邬袁凯

1个回答

0 投票
 
已采纳
创建bounds边界类实例,把查询到的点线面坐标赋值给这个边界类。
然后用map.zoomToExtent(bounds);去执行就好了。
11月 6, 2019 用户: 27。 名扬四海 (1,064 分)
采纳于 11月 7, 2019 用户:weixixi
请问能详细讲一下吗?用了示例的代码

       

function init() {
        map = new SuperMap.Map("map", {
            controls: [
                new SuperMap.Control.ScaleLine(),
                new SuperMap.Control.Zoom(),
                new SuperMap.Control.Navigation({
                    dragPanOptions: {
                        enableKinetic: true
                    }
                })]
        });
        map.addControl(new SuperMap.Control.LayerSwitcher(), new SuperMap.Pixel(42, 80));
        layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", url, {
            transparent: true,
            cacheEnabled: true
        }, {maxResolution: "auto"});
        layer.events.on({"layerInitialized": addLayer});
        vectorLayer = new SuperMap.Layer.Vector("Vector Layer");
    }

    function addLayer() {
        map.addLayers([layer, vectorLayer]);
        map.setCenter(new SuperMap.LonLat(106.3, 37), 2);
    }

    function queryBySQL() {
        vectorLayer.removeAllFeatures();

        var queryParam, queryBySQLParams, queryBySQLService;
        queryParam = new SuperMap.REST.FilterParameter({
            name: "Countries@World.1",
            attributeFilter: "Pop_1994>1000000000 and SmArea>900"
        });
        queryBySQLParams = new SuperMap.REST.QueryBySQLParameters({
            queryParams: [queryParam]
        });
        queryBySQLService = new SuperMap.REST.QueryBySQLService(url, {
            eventListeners: {"processCompleted": processCompleted, "processFailed": processFailed}
        });
        queryBySQLService.processAsync(queryBySQLParams);
    }

    function processCompleted(queryEventArgs) {
        var i, j, feature,
            result = queryEventArgs.result;
        if (result && result.recordsets) {
            for (i = 0; i < result.recordsets.length; i++) {
                if (result.recordsets[i].features) {
                    for (j = 0; j < result.recordsets[i].features.length; j++) {
                        feature = result.recordsets[i].features[j];
                        feature.style = style;
                        vectorLayer.addFeatures(feature);
                    }
                }
            }
        }
    }

    function processFailed(e) {
        widgets.alert.showAlert(e.error.errorMsg, false);
    }

    function clearFeatures() {
        //先清除上次的显示结果
        vectorLayer.removeAllFeatures();
        vectorLayer.refresh();
    }
...