使用产品:iclient for leaflet 操作系统:win10 x64
http://ask.supermap.com/66316之前看过了这一篇帖子,并且按照回答进行了修改,但还是无法解决, 代码如下
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Supermap</title>
<script type="text/javascript" src="../js/include-web.js"></script>
</head>
<body style=" margin:0px;overflow: hidden;background:rgb(32, 23, 160);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/leaflet/include-leaflet.js"></script>
<script type="text/javascript">
var map, url ="http://localhost:8090/iserver/services/map-EmergWS/rest/maps/EmergMap";
crs=L.Proj.CRS("EPSG:3857",{origin:[11543699.56 , 3582305.28],
scaleDenominators: [50000,40000,25000, 20000, 10000, 5000, 2000, 1000, 500, 200, 100, 50, 20, 1]});
var pt=crs.unproject(L.point(11543699.56 , 3582305.28));
map = L.map('map', {
center: [pt.lat,pt.lng],
maxZoom: 18,
minZoom: 1,
zoom: 1,
crs:crs
});
L.supermap.imageMapLayer(url, {transparent: false}).addTo(map);
//缓冲区分析
bufferAnalystProcess();
function bufferAnalystProcess() {
var serviceUrl="http://localhost:8090/iserver/services/spatialAnalysis-EmergWS/restjsr/spatialanalyst";
dsBufferAnalystService = L.supermap.spatialAnalystService(serviceUrl);
dsBufferAnalystParameters = new SuperMap.DatasetBufferAnalystParameters({
dataset: "Chemical_Factory@EmergDS",
filterQueryParameter: new SuperMap.FilterParameter({
attributeFilter: "Name='铝业化工厂'"
}),
bufferSetting: new SuperMap.BufferSetting({
endType: SuperMap.BufferEndType.ROUND,
leftDistance: {value: 100},
semicircleLineSegment: 10
})
});
dsBufferAnalystService.bufferAnalysis(dsBufferAnalystParameters, function (serviceResult) {
var result = L.Util.transform(serviceResult.result.recordset.features, L.CRS.EPSG4326, L.CRS.EPSG3857);
resultLayer = L.geoJSON(result).addTo(map);
});
}
</script>
</body>
</html>
根据http://localhost:8090/iserver/iClient/forJavaScript/examples/leaflet/editor.html#01_mapQueryByGeometry3857网站上所说,因为leaflet 绘制数据默认为 4326,服务器返回数据为 3857,因此在加载到地图前,先进行坐标系转换。并且使用到的数据集的投影坐标系也改为3857,且服务已发布成功。
错误提示如下,且调用数组时写“serviceResult.result.recordset.features”,或“serviceResult.result.recordset.features.features”都是这个错误提示
控制台中显示已经成功读入,如图,