首页 / 浏览问题 / WebGIS / 问题详情
iserver问题
6EXP 2020年07月09日
<div id="map" style="position: absolute;top: 0px; height:500px;left:0px;right: 0px;background-color:white;"></div>
	<script type="text/javascript">
		var resultLayer,map;
		var mapurl='http://localhost:8090/iserver/services/map-China100-1/rest/maps/China';
		var dataURL='http://localhost:8090/iserver/services/data-China100-1-3/rest/data';
		map=L.map('map', {
        	preferCanvas: true,
        	center: [39, 100],
        	maxZoom: 18,
        	zoom: 5
    	});
        L.supermap.tiledMapLayer(mapurl).addTo(map);
    	query();

    	function query(){
            var param=new SuperMap.GetFeaturesBySQLParameters({
                queryParameter: {
                    name: "China_Province_pg@China",
                    attributeFilter: "SMID = 10 "
                },
                datasetNames:["China:China_Province_pg"]
            });
            console.log(param);
            L.supermap.featureService(dataURL).getFeaturesBySQL(param,function(serviceResult){
                var result=serviceResult.result.features;

                console.log(result);
                L.geoJSON(serviceResult.result.features).addTo(map).bindPopup('SMID = 10');
            });
        }	

    </script>

以上是我的代码

<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
<script type="text/javascript" src="../../dist/leaflet/include-leaflet.js"></script>
<script type="text/javascript">
    var host = window.isLocal ? window.server : "https://iserver.supermap.io";
    var map, resultLayer,
        baseUrl ="https://iserver.supermap.io/iserver/services/map-world/rest/maps/World",
        url ="https://iserver.supermap.io/iserver/services/data-world/rest/data";
    map = L.map('map', {
        preferCanvas: true,
        crs: L.CRS.EPSG4326,
        center: {lon: 0, lat: 0},
        maxZoom: 18,
        zoom: 1
    });
    L.supermap.tiledMapLayer(baseUrl).addTo(map);
    query();

    function query() {
        var sqlParam = new SuperMap.GetFeaturesBySQLParameters({
            queryParameter: {
                name: "Countries@World",
                attributeFilter: "SMID = 247"
            },
            datasetNames: ["World:Countries"]
        });
                    console.log(sqlParam);

        L.supermap
            .featureService(url)
            .getFeaturesBySQL(sqlParam, function (serviceResult) {
                var result=serviceResult.result.features;

                console.log(result);
                L.geoJSON(serviceResult.result.features).addTo(map).bindPopup('SMID = 247');
            });
    }
</script>

该段是参照贵司的代码

结果比较,结果是同样输出的是对象,但我用l.geojson加载geojson图层结果如下

1个回答

您好,您可以看下返回的要素坐标是否是地理坐标。leaflets使用地理坐标系的方式展示数据的,如果您返回的投影坐标系的要素对象, 需要进行数据坐标转换才能正常显示出图您可以参考该范例https://blog.csdn.net/supermapsupport/article/details/79581665

3,357EXP 2020年07月09日
...