-
Notifications
You must be signed in to change notification settings - Fork 288
Expand file tree
/
Copy path01_mapService.html
More file actions
77 lines (70 loc) · 2.89 KB
/
01_mapService.html
File metadata and controls
77 lines (70 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!--********************************************************************
* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title data-i18n="resources.title_mapService"></title>
<script type="text/javascript" src="../js/include-web.js"></script>
<style>
.mapboxgl-popup-close-button {
outline: none;
}
</style>
</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/mapboxgl/include-mapboxgl.js"></script>
<script type="text/javascript">
var host = window.isLocal ? window.server : "https://iserver.supermap.io";
var url = host + "/iserver/services/map-world/rest/maps/World";
var attribution = "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
"with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
" Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> ";
var map = new mapboxgl.Map({
container: 'map',
style: {
"version": 8,
"sources": {
"raster-tiles": {
"attribution": attribution,
"type": "raster",
"tiles": [host + '/iserver/services/maps/rest/maps/World/zxyTileImage.png?prjCoordSys=' + encodeURIComponent('{"epsgCode":3857}') + '&z={z}&x={x}&y={y}'],
"tileSize": 256,
},
},
"layers": [{
"id": "simple-tiles",
"type": "raster",
"source": "raster-tiles",
"minzoom": 0,
"maxzoom": 22
}]
},
center: [-74.50, 40],
maxZoom: 18,
zoom: 2
});
map.addControl(new mapboxgl.supermap.LogoControl({ link: "https://iclient.supermap.io" }), 'bottom-right');
map.addControl(new mapboxgl.NavigationControl(), 'top-left');
map.on('load', function () {
mapService();
});
function mapService() {
new mapboxgl.supermap.MapService(url).getMapInfo().then(callback);
}
function callback(serviceResult) {
var result = serviceResult.result;
var innerHTML = "(" + resources.text_mapInfoPrint + ")" + "<br><br>";
innerHTML += resources.text_mapName + ":" + JSON.stringify(result.name) + "<br>";
innerHTML += resources.text_center + ":" + JSON.stringify(result.center) + "<br>";
innerHTML += "Bounds:" + JSON.stringify(result.bounds) + "<br>";
new mapboxgl.Popup({ closeOnClick: false })
.setLngLat([-96, 37.8])
.setHTML("<div style='word-wrap: break-word;'>" + innerHTML + "</br>"+ "</div>")
.addTo(map);
}
</script>
</body>
</html>