<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>地图叠加</title>
<script type="text/javascript" src="dist/leaflet/include-leaflet.js"></script>
<script src="./leaflet-measure-path.js"></script>
<script src="ZJ.js"></script>
<body style="margin: 0;overflow: hidden;background: rgb(212, 62, 62);width: 100%;height: 100%;position: absolute;top: 0" >
<!-- 添加承载地图控件的容器 -->
<div id="map-distance" style="z-index: 2000;">
<span>量距</span>
</div>
<div id="map" style="margin:0 auto;width: 100%;height:100%"></div>
<script type="text/javascript">
// 设置访问的GIS服务地址
var url="http://222.84.136.150:8081/geoesb/proxy/f6b3c78a553843919b45ca9d0be09cc2/886e60bb7e014f22a707de23e6f6505d";
var scaleDenominators = [591658710.90831, 295829355.454155,
147914677.727296,73957338.8636482,36978669.4318241,18489334.715912,9244667.357942339,4622333.678977581,2311166.8394887904,1155583.4197443998,577791.709872198,288895.854936099,144447.92746804998,72223.9637340248,36111.9818670124,18055.9909335062,9027.9954667531,4513.99773337655,2256.99886668828];
var origin = [-180.0,90.0];
// var urlrest ="http://222.84.136.150:8081/geoesb/proxy/80f84391c26649948456e5440dafb344/886e60bb7e014f22a707de23e6f6505d";
// var urlrest ="http://192.168.48.119:8090/iserver/services/map-XZQJDDT/wmts100";
var res = [1.4062499999980482,0.7031249999990241,0.3515625000000313,0.17578125000001618,0.08789062500000809,0.043945312500003914,0.021972656249969493,0.010986328124999981,0.0054931640624999905,0.002746582031250007,0.0013732910156249987,0.0006866455078124993,0.00034332275390625087,0.00017166137695312497,0.00008583068847656249,0.00004291534423828124,0.00002145767211914062,0.00001072883605957031,0.000005364418029785168];
// 创建地图对象
map = L.map("map",{
center:[24.2,109.4],
zoom:15,
crs:new L.Proj.CRS("EPSG:4326",{
origin: origin,
scaleDenominators: scaleDenominators,
resolutions: res
}),
bound:L.bounds([-180.0,-90.0],[180.0,90.0])
});
L.supermap.wmtsLayer(url,{
layer:"GOVMAP",
style:"default",
tilematrixSet:"CustomCRS4490ScaleGOVMAP",
format:"image/png"
}).addTo(map)
// L.supermap.tiledMapLayer(urlrest, {
// // transparent: true,
// // opacity: 0.6
// }).addTo(map);
//多边形
var polygon = L.polygon([
[24.2,109.4],
[24.2,109.5],
[24.3,109.5],
[24.3,109.4],
], { showMeasurements: true })
.addTo(map);
//距离
L.polyline([
[24.5,109.4],
[24.5,109.6],
[24.4,109.4],
],
{
showMeasurements: true,
measurementOptions: { imperial: true}
})
.addTo(map);
L.control.layers().addTo(map);
layerService();
function layerService() {
L.supermap
.layerInfoService(url,{
proxy: "http://localhost:8090/GettingStart/httpproxy/httpproxy.jsp?url=http://222.84.136.150:8081/geoesb/proxy/f6b3c78a553843919b45ca9d0be09cc2/886e60bb7e014f22a707de23e6f6505d",
crossOrigin: true,
})
.getLayersInfo(function (serviceResult) {
var result = serviceResult.result;
var innerHTML = "";
result.subLayers.layers.map(function (layer) {
innerHTML += layer.name + "<br>";
});
infowin = L.popup({maxWidth: 400})
.setLatLng(map.getCenter())
.setContent(innerHTML)
.openOn(map);
});
console.log(serviceResult);
}
</script>
</body>
</html>
Uncaught ReferenceError: serviceResult is not defined
at layerService (量距量面.html:90)
at 量距量面.html:71
量距量面.html:82 Uncaught (in promise) TypeError: Cannot read property 'subLayers' of undefined
at Bs.<anonymous> (量距量面.html:82)
at Ie.triggerEvent (iclient-leaflet-es6.min.js:101)
at Bs.serviceProcessFailed (iclient-leaflet-es6.min.js:218)
at Bs.getUrlFailed (iclient-leaflet-es6.min.js:218)
at iclient-leaflet-es6.min.js:28
at iclient-leaflet-es6.min.js:218
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title data-i18n="resources.title_mapQueryByGeometry"></title>
<script type="text/javascript" include="widgets" src="js/include-web.js"></script>
</head>
<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/leaflet/include-leaflet.js"></script>
<script type="text/javascript">
var map, resultLayer,
url = "";
map = L.map('map', {
preferCanvas: true,
center: [39, 100],
maxZoom: 18,
zoom: 5
});
L.supermap.tiledMapLayer(url).addTo(map);
query();
function query() {
var polygon = L.polygon([[38, 100], [36, 110], [35, 105], [38, 100]], {color: 'red'});
polygon.addTo(map);
//服务端数据坐标系为 3857,因此将查询数据转为与服务端对应坐标系:
var geometry = L.Util.transform(polygon, L.CRS.EPSG4326, L.CRS.EPSG3857);
var param = new SuperMap.QueryByGeometryParameters({
queryParams: {name: "China_Province_pl@China"},
geometry: geometry
});
widgets.loader.showLoader();
L.supermap
.queryService(url)
.queryByGeometry(param, function (serviceResult) {
//leaflet 绘制数据默认为 4326,服务器返回数据为 3857,因此在加载到地图前,先进行坐标系转换:
var result = L.Util.transform(serviceResult.result.recordsets[0].features, L.CRS.EPSG3857, L.CRS.EPSG4326);
widgets.loader.removeLoader();
resultLayer = L.geoJSON(result).addTo(map);
polygon.remove();
polygon.addTo(map);
});
}
</script>
</body>
</html>
Uncaught ReferenceError: widgets is not defined
at query (柳州.html:39)
at 柳州.html:27