Skip to content

Commit 9dde4bb

Browse files
authored
Add files via upload
添加测试代码
1 parent 35e9a4a commit 9dde4bb

File tree

5 files changed

+431
-0
lines changed

5 files changed

+431
-0
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<!--********************************************************************
2+
* Copyright© 2000 - 2020 SuperMap Software Co.Ltd. All rights reserved.
3+
*********************************************************************-->
4+
<!DOCTYPE html>
5+
<html>
6+
<head>
7+
<meta charset="UTF-8">
8+
<title>温榆河公园-嵌套图层</title>
9+
<script type="text/javascript" src="../js/include-web.js"></script>
10+
<!-- <script type="text/javascript" include="jquery" src="../js/include-web.js"></script>-->
11+
</head>
12+
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
13+
<input type="button" onclick="RouteSolve()" value="路径分析"/>
14+
<input type="button" onclick="projectTrance()" value="转换坐标"/>
15+
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
16+
<script type="text/javascript" src="../../dist/leaflet/include-leaflet.js"></script>
17+
<script type="text/javascript">
18+
19+
var host = window.isLocal ? window.server : "https://iserver.supermap.io";
20+
var map, url = host + "/iserver/services/map-china400/rest/maps/China";
21+
map = L.map('map', {
22+
center: [40.07,116.46],
23+
maxZoom: 20,
24+
zoom: 15
25+
});
26+
L.supermap.tiledMapLayer(url).addTo(map);
27+
28+
L.supermap.wmtsLayer("http://116.117.157.183:25599/wenyuhe_baidu/MapServer/WMTS",
29+
// L.supermap.wmtsLayer("http://116.117.157.183:25597/arcgis/rest/services/wyh/wenyuhe_baidu/MapServer/WMTS",
30+
{
31+
layer: "wenyuhe_baidu",
32+
style: "default",
33+
tilematrixSet: "default028mm",
34+
format: "image/jpgpng",
35+
opacity:1,
36+
requestEncoding: 'KVP'
37+
}
38+
).addTo(map);
39+
/**
40+
* 坐标转换
41+
*/
42+
function projectTrance(){
43+
var projection = L.CRS.EPSG3857.projection;
44+
var latlng=projection.project(L.latLng(40.0756594477,116.458870653));
45+
console.log(latlng);
46+
var latlng1=projection.unproject(L.point(12963918.991365522,4877080.510116231));
47+
console.log(latlng1);
48+
var latlng2=projection.unproject(L.point(12964004.983022345,4877333.707772432));
49+
console.log(latlng2);
50+
}
51+
/**
52+
* 最优路径查询
53+
* @constructor
54+
*/
55+
function RouteSolve() {
56+
// var url = 'http://116.117.157.183:25597/arcgis/rest/services/wyh/networkAnalyst/NAServer/Route/solve';
57+
var url = 'http://116.117.157.183:25599/networkAnalyst/NAServer/Route/solve';
58+
var data={stops:[[116.45905440286576,40.07801667086068],[116.45643656686717,40.0763419393556]],
59+
ignoreInvalidLocations: true, returnDirections: false,
60+
impedanceAttributeName: 'Length',
61+
restrictUTurns: 'esriNFSBAllowBacktrack',
62+
returnRoutes: true,outSR:'4326',
63+
outputLines: 'esriNAOutputLineTrueShape',
64+
directionsOutputType: 'esriDOTComplete',
65+
f: 'pjson'};
66+
67+
//
68+
$.ajax({
69+
dataType: 'json',
70+
data:data,
71+
url: url,
72+
success: function (result) {
73+
var latlngs=result.routes.features[0].geometry.paths[0];
74+
var lnglatArr=new Array();
75+
for(var i=0;i<latlngs.length;i++){
76+
var arr=new Array(latlngs[i][1],latlngs[i][0]);
77+
lnglatArr.push(arr);
78+
}
79+
var polyline = L.polyline(lnglatArr, {color: 'red'}).addTo(map);
80+
map.fitBounds(polyline.getBounds());
81+
},
82+
error: function (jqXHR, status, errorThrown) {
83+
console.log(status, errorThrown);
84+
}
85+
});
86+
}
87+
88+
</script>
89+
</body>
90+
</html>
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<!--********************************************************************
2+
* Copyright© 2000 - 2020 SuperMap Software Co.Ltd. All rights reserved.
3+
*********************************************************************-->
4+
<!DOCTYPE html>
5+
<html>
6+
<head>
7+
<meta charset="UTF-8">
8+
<title>温榆河公园-嵌套图层</title>
9+
<script type="text/javascript" src="../js/include-web.js"></script>
10+
<!-- <script type="text/javascript" include="jquery" src="../js/include-web.js"></script>-->
11+
</head>
12+
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
13+
<input type="button" onclick="RouteSolve()" value="路径分析"/>
14+
<input type="button" onclick="projectTrance()" value="转换坐标"/>
15+
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
16+
<script type="text/javascript" src="../../dist/leaflet/include-leaflet.js"></script>
17+
<script type="text/javascript">
18+
19+
var host = window.isLocal ? window.server : "https://iserver.supermap.io";
20+
var map, url = host + "/iserver/services/map-china400/rest/maps/China";
21+
map = L.map('map', {
22+
center: [40.07,116.46],
23+
maxZoom: 20,
24+
zoom: 15
25+
});
26+
L.supermap.tiledMapLayer(url).addTo(map);
27+
28+
L.supermap.wmtsLayer("http://116.117.157.183:25599/wenyuhe_baidu/MapServer/WMTS",
29+
// L.supermap.wmtsLayer("http://116.117.157.183:25597/arcgis/rest/services/wyh/wenyuhe_baidu/MapServer/WMTS",
30+
{
31+
layer: "wenyuhe_baidu",
32+
style: "default",
33+
tilematrixSet: "default028mm",
34+
format: "image/jpgpng",
35+
opacity:1,
36+
requestEncoding: 'KVP'
37+
}
38+
).addTo(map);
39+
/**
40+
* 坐标转换
41+
*/
42+
function projectTrance(){
43+
var projection = L.CRS.EPSG3857.projection;
44+
var latlng=projection.project(L.latLng(40.0756594477,116.458870653));
45+
console.log(latlng);
46+
var latlng1=projection.unproject(L.point(12963918.991365522,4877080.510116231));
47+
console.log(latlng1);
48+
var latlng2=projection.unproject(L.point(12964004.983022345,4877333.707772432));
49+
console.log(latlng2);
50+
}
51+
/**
52+
* 最优路径查询
53+
* @constructor
54+
*/
55+
function RouteSolve() {
56+
var projection = L.CRS.EPSG3857.projection;
57+
var latlngS=projection.project(L.latLng(40.07958941310,116.46140178400));
58+
var latlngE=projection.project(L.latLng(40.07516150480,116.46120913200));
59+
// var url = 'http://116.117.157.183:25599/networkAnalyst/NAServer/Route/solve';
60+
// var url='http://116.117.157.183:25597/arcgis/rest/services/wyh/networkAnalyst/NAServer/Route/solve';
61+
var url = 'http://223.70.181.107:6083/wyh/networkAnalyst/NAServer/Route/solve';
62+
//投影坐标方式
63+
var data={stops:'{"type":"features","features":[' +
64+
'{"geometry":{"x":'+latlngS.x+',"y":'+latlngS.y+',"spatialReference":{"wkid":102100,"latestWkid":3857}}},' +
65+
'{"geometry":{"x":'+latlngE.x+',"y":'+latlngE.y+',"spatialReference":{"wkid":102100,"latestWkid":3857}}}],' +
66+
'"doNotLocateOnRestrictedElements":true}',
67+
ignoreInvalidLocations: true, returnDirections: false,
68+
impedanceAttributeName: 'Length',
69+
restrictUTurns: 'esriNFSBAllowBacktrack',
70+
returnRoutes: true,outSR:'4326',
71+
outputLines: 'esriNAOutputLineTrueShape',
72+
directionsOutputType: 'esriDOTComplete',
73+
f: 'pjson'};
74+
//经纬度方式
75+
// var data={stops:'{"type":"features","features":[{"geometry":{"x":116.46140178400,"y":40.07958941310,"spatialReference":{"wkid":4326}}},' +
76+
// '{"geometry":{"x":116.46120913200,"y":40.07516150480,"spatialReference":{"wkid":4326}}}],"doNotLocateOnRestrictedElements":true}',
77+
// ignoreInvalidLocations: true, returnDirections: false,
78+
// impedanceAttributeName: 'Length',
79+
// restrictUTurns: 'esriNFSBAllowBacktrack',
80+
// returnRoutes: true,outSR:'4326',
81+
// outputLines: 'esriNAOutputLineTrueShape',
82+
// directionsOutputType: 'esriDOTComplete',
83+
// f: 'pjson'};
84+
85+
//发送请求
86+
$.ajax({
87+
dataType: 'json',
88+
data:data,
89+
url: url,
90+
success: function (result) {
91+
var latlngs=result.routes.features[0].geometry.paths[0];
92+
console.log(latlngs);
93+
var lnglatArr=new Array();
94+
for(var i=0;i<latlngs.length;i++){
95+
var arr=new Array(latlngs[i][1],latlngs[i][0]);
96+
lnglatArr.push(arr);
97+
}
98+
console.log(lnglatArr);
99+
var polyline = L.polyline(lnglatArr, {color: 'red'}).addTo(map);
100+
map.fitBounds(polyline.getBounds());
101+
},
102+
error: function (jqXHR, status, errorThrown) {
103+
console.log(status, errorThrown);
104+
}
105+
});
106+
}
107+
108+
</script>
109+
</body>
110+
</html>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!--********************************************************************
2+
* Copyright© 2000 - 2020 SuperMap Software Co.Ltd. All rights reserved.
3+
*********************************************************************-->
4+
<!DOCTYPE html>
5+
<html>
6+
<head>
7+
<meta charset="UTF-8">
8+
<title>温榆河公园-嵌套图层</title>
9+
<script type="text/javascript" src="../js/include-web.js"></script>
10+
<!-- <script type="text/javascript" include="jquery" src="../js/include-web.js"></script>-->
11+
</head>
12+
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
13+
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
14+
<script type="text/javascript" src="../../dist/leaflet/include-leaflet.js"></script>
15+
<script type="text/javascript">
16+
17+
var host = window.isLocal ? window.server : "https://iserver.supermap.io";
18+
var map, url = host + "/iserver/services/map-china400/rest/maps/China";
19+
map = L.map('map', {
20+
center: [40.07,116.46],
21+
maxZoom: 22,
22+
zoom: 15
23+
});
24+
L.control.scale().addTo(map);
25+
// L.supermap.tiledMapLayer(url).addTo(map);
26+
L.supermap.wmtsLayer("http://223.70.181.107:6083/wyh/wenyuhe_/MapServer/WMTS",
27+
{
28+
maxZoom:19,
29+
layer: "wenyuhe",
30+
style: "default",
31+
tilematrixSet: "default028mm",
32+
format: "image/jpgpng",
33+
opacity:1,
34+
requestEncoding: 'KVP'
35+
}
36+
).addTo(map);
37+
38+
</script>
39+
</body>
40+
</html>

examples/leaflet/00_WMTS_Layer.html

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<!--********************************************************************
2+
* Copyright© 2000 - 2020 SuperMap Software Co.Ltd. All rights reserved.
3+
*********************************************************************-->
4+
<!DOCTYPE html>
5+
<html>
6+
<head>
7+
<meta charset="UTF-8">
8+
<title>温榆河公园-嵌套图层</title>
9+
<script type="text/javascript" src="../js/include-web.js"></script>
10+
<!-- <script type="text/javascript" include="jquery" src="../js/include-web.js"></script>-->
11+
</head>
12+
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
13+
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
14+
<script type="text/javascript" src="../../dist/leaflet/include-leaflet.js"></script>
15+
<script type="text/javascript">
16+
17+
// var map;
18+
// //自定义比例尺
19+
// var crs=L.Proj.CRS("EPSG:3857", {
20+
// origin:[-20037508.34,20037508.34],
21+
// scaleDenominators:[559082264.02850163,279541132.01425034,139770566.00712562,69885283.003562346,34942641.501781173,17471320.750890587,8735660.3754452933,4367830.1877226466,2183915.0938617955,1091957.5469304253,545978.77346568508,272989.38673237007,136494.69336618503,68247.346683092517,34123.673341546259,17061.836671245605,8530.9183356228023,4265.4591673389286,2132.7295841419359,1066.3647915984968,503.82663472020585,251.91331736010292]
22+
// });
23+
//
24+
// map = L.map('map', {
25+
// center: [40.07,116.46],
26+
// maxZoom: 22,
27+
// zoom: 15,
28+
// crs:crs
29+
// });
30+
// L.control.scale().addTo(map);
31+
32+
// L.supermap.wmtsLayer("http://223.70.181.107:6083/wyh/wenyuhe/MapServer/WMTS",
33+
// {
34+
// maxZoom:20,
35+
// layer: "wenyuhe",
36+
// style: "default",
37+
// tilematrixSet: "default028mm",
38+
// format: "image/jpgpng",
39+
// opacity:1,
40+
// requestEncoding: 'KVP'
41+
// }
42+
// ).addTo(map);
43+
44+
http://10.32.5.18:6080/arcgis/rest/services/wyh/wenyuhe_500/MapServer/WMTS/tile/1.0.0/wyh_wenyuhe_500/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png
45+
46+
47+
var crs =L.Proj.CRS("EPSG:3857",{
48+
// origin: [12964874.08375, 4876626.52588],
49+
// bounds: L.bounds([12962796.043902915,4874100.4430881925],[12967045.795061948,4878350.194216478]),
50+
resolutions: [147924.14487249748, 73962.0724362486, 36981.03621812443, 18490.51810906209, 9245.259054531045, 4622.6295272655225, 2311.3147636327612, 1155.6573818163806, 577.8286909083153, 288.9143454540326, 144.4571727271413, 72.22858636344564, 36.11429318172282, 18.05714659086141, 9.028573295430705, 4.514286647840362, 2.257143323920181, 1.1285716618350818, 0.5642858310425494, 0.2821429153962664, 0.1333043970451819, 0.06665219852259095],
51+
});
52+
53+
let map = L.map('map', {
54+
crs:crs,
55+
center: [12964874.08375, 4876626.52588],
56+
maxZoom: 20,
57+
zoom: 15
58+
});
59+
60+
let extent = L.tileLayer.wms("http://223.70.181.107:6083/cache/service/wms", {
61+
layers: 'GD:wyh_wenyuhe_500',
62+
format: 'image/png',
63+
transparent: true
64+
}).addTo(map);
65+
66+
// L.supermap.wmtsLayer("http://223.70.181.107:6083/wyh/wenyuhe_500/MapServer/WMTS",
67+
// {
68+
// maxZoom:22,
69+
// layer: "wenyuhe_500",
70+
// style: "default",
71+
// tilematrixSet: "default028mm",
72+
// format: "image/png",
73+
// opacity:1,
74+
// requestEncoding: 'KVP'
75+
// }
76+
// ).addTo(map);
77+
78+
// http://223.70.181.107:6083/wyh/wenyuhe_500/MapServer/WMTS
79+
80+
// let bounds = [
81+
// [4875732, 12962563],
82+
// [4877838, 12962563],
83+
// ];
84+
// // http://223.70.181.107:6082/arcgis/rest/services/wyh/wenyuhe/MapServer/WMTS/tile/1.0.0/wyh_wenyuhe/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png
85+
//
86+
// L.tileLayer(
87+
// `http://223.70.181.107:6083/wyh/wenyuhe/MapServer/WMTS?layer=&style=&tilematrixset=EPSG 3857&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/png&TileMatrix=EPSG 3857:{z}&TileCol={x}&TileRow={y}`,
88+
// {
89+
// bounds//配置bounds属性之后,只会在指定的区域内加载切片服务,解决400问题,(现在可以正常捕捉图层加载异常)
90+
// //注意:因为配置了该属性只会在指定区域加载切片服务,所以用tileerror事件监听图层加载失败时,只有地图移动到这个范围内才会被监听到
91+
// }
92+
// ).addTo(map);
93+
94+
// xmax: 12967120.583248805
95+
// xmin: 12962563.02543718
96+
// ymax: 4877838.804579157
97+
// ymin: 4875732.008986991
98+
99+
// let bounds = [
100+
// [40.798808032020915, 107.81011442414682],
101+
// [40.79334985056709, 107.77521227880288],
102+
// ];
103+
// let map = L.map('map');
104+
// map.fitBounds(bounds);
105+
// L.tileLayer(
106+
// `http://ddns.zatxtech.com:8443/geoserver/gwc/service/wmts?layer=hjq-tif:hjq-mosaic&style=&tilematrixset=EPSG 3857&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/png&TileMatrix=EPSG 3857:{z}&TileCol={x}&TileRow={y}`,
107+
// {
108+
// bounds//配置bounds属性之后,只会在指定的区域内加载切片服务,解决400问题,(现在可以正常捕捉图层加载异常)
109+
// //注意:因为配置了该属性只会在指定区域加载切片服务,所以用tileerror事件监听图层加载失败时,只有地图移动到这个范围内才会被监听到
110+
// }
111+
// ).addTo(map);
112+
113+
</script>
114+
</body>
115+
</html>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy