|
| 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 | + <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /> |
| 9 | + <title data-i18n="resources.title_tiledMapLayer"></title> |
| 10 | + <script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script> |
| 11 | + <style> |
| 12 | + body { |
| 13 | + margin: 0; |
| 14 | + padding: 0; |
| 15 | + } |
| 16 | + |
| 17 | + #map { |
| 18 | + position: absolute; |
| 19 | + top: 0; |
| 20 | + bottom: 0; |
| 21 | + width: 100%; |
| 22 | + } |
| 23 | + .btn { |
| 24 | + position: absolute; |
| 25 | + left: 60px; |
| 26 | + top: 10px; |
| 27 | + text-align: center; |
| 28 | + background: #fff; |
| 29 | + z-index: 1000; |
| 30 | + } |
| 31 | + </style> |
| 32 | + </head> |
| 33 | + <body> |
| 34 | + <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_objectdetection" onclick="addResultLayer()" /> |
| 35 | + <div id="map"></div> |
| 36 | + <script |
| 37 | + type="text/javascript" |
| 38 | + exclude="iclient-mapboxgl" |
| 39 | + src="../../dist/mapboxgl/include-mapboxgl.js" |
| 40 | + ></script> |
| 41 | + <script type="text/javascript"> |
| 42 | + var host = window.isLocal ? window.server : 'https://iserver.supermap.io'; |
| 43 | + var attribution = |
| 44 | + "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" + |
| 45 | + " with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" + |
| 46 | + " Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> "; |
| 47 | + |
| 48 | + var map = new mapboxgl.Map({ |
| 49 | + container: 'map', |
| 50 | + style: { |
| 51 | + version: 8, |
| 52 | + sources: { |
| 53 | + 'raster-tiles': { |
| 54 | + attribution: attribution, |
| 55 | + type: 'raster', |
| 56 | + tiles: [ |
| 57 | + host + '/iserver/services/map-plane/rest/maps/plane/zxyTileImage.png?z={z}&x={x}&y={y}' |
| 58 | + ], |
| 59 | + tileSize: 256 |
| 60 | + } |
| 61 | + }, |
| 62 | + layers: [ |
| 63 | + { |
| 64 | + id: 'simple-tiles', |
| 65 | + type: 'raster', |
| 66 | + source: 'raster-tiles', |
| 67 | + minzoom: 0, |
| 68 | + maxzoom: 22 |
| 69 | + } |
| 70 | + ] |
| 71 | + }, |
| 72 | + center: [-87.89799410302197, 41.97732379151233], // starting position |
| 73 | + zoom: 15.8 // starting zoom |
| 74 | + }); |
| 75 | + map.addControl(new mapboxgl.NavigationControl(), 'top-left'); |
| 76 | + function addResultLayer() { |
| 77 | + if (map.getLayer('result-layer')) { |
| 78 | + map.removeLayer('result-layer'); |
| 79 | + } |
| 80 | + if (map.getSource('result-layer')) { |
| 81 | + map.removeSource('result-layer'); |
| 82 | + } |
| 83 | + map.addLayer({ |
| 84 | + id: 'result-layer', |
| 85 | + type: 'raster', |
| 86 | + source: { |
| 87 | + attribution: attribution, |
| 88 | + type: 'raster', |
| 89 | + tiles: [ |
| 90 | + host + |
| 91 | + '/iserver/services/map-plane/rest/maps/result_plane/zxyTileImage.png?z={z}&x={x}&y={y}&transparent=true' |
| 92 | + ], |
| 93 | + tileSize: 256 |
| 94 | + }, |
| 95 | + minzoom: 0, |
| 96 | + maxzoom: 22 |
| 97 | + }); |
| 98 | + } |
| 99 | + </script> |
| 100 | + </body> |
| 101 | +</html> |
0 commit comments