我使用iclient of leaflet数据服务SQL查询 ,也看过举例的代码发现无法查询 F12报错如下
Uncaught (in promise) TypeError: Cannot read property 'features' of undefined
at t.<anonymous> (古树SQL - 副本 - 副本.html:36)
at e.value (iclient9-leaflet.min.js:8)
at t.value [as _processFailed] (iclient9-leaflet.min.js:8)
at t.value (iclient9-leaflet.min.js:8)
at iclient9-leaflet.min.js:8
at iclient9-leaflet.min.js:8
但是我用地图服务查询能出来结果,但是getfeature 一定要用到数据服务的地址,无法解决我的问题,想请问一下怎么解决
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
<script type="text/javascript" src="dist/include-leaflet.js"></script>
<script type="text/javascript">
var host = window.isLocal ? window.server : "http://localhost:8090";
var map, resultLayer,
baseUrl = host + "/iserver/services/map-TM11/rest/maps/zongTM";
url = host + "/iserver/services/data-TM11/rest/data",
map = L.map('map', {
center: {lon: 119.51, lat: 30.35},
crs: L.CRS.EPSG4326,
zoom:11.2
});
L.supermap.tiledMapLayer(baseUrl).addTo(map);
query();
function query() {
var sqlParam = new SuperMap.GetFeaturesBySQLParameters({
queryParams: {
name: "林场古树名木_2@tm9",
attributeFilter: "SMID>0"
},
datasetNames: ["tm9:林场古树名木_2"]
});
L.supermap
.featureService(url)
.getFeaturesBySQL(sqlParam, function (serviceResult) {
resultLayer = L.geoJSON(serviceResult.result.features).addTo(map).bindPopup('SMID = 247');
});
}
</script>
</body>