graticuleLayer_3857.html 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
  6. <title data-i18n="resources.title_graticuleLayer_3857"></title>
  7. <script type="text/javascript" src="../js/include-web.js"></script>
  8. <script type="text/javascript" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
  9. <style>
  10. body {
  11. margin: 0;
  12. padding: 0;
  13. }
  14. #map {
  15. position: absolute;
  16. top: 0;
  17. bottom: 0;
  18. width: 100%;
  19. }
  20. </style>
  21. </head>
  22. <body>
  23. <div id="map"></div>
  24. <script type="text/javascript">
  25. var host = window.isLocal ? window.server : 'https://iserver.supermap.io';
  26. var map = new mapboxgl.Map({
  27. container: 'map', // container id
  28. style: {
  29. version: 8,
  30. sources: {
  31. 'raster-tiles': {
  32. type: 'raster',
  33. tiles: [
  34. host +
  35. '/iserver/services/map-china400/rest/maps/China/zxyTileImage.png?z={z}&x={x}&y={y}'
  36. ],
  37. tileSize: 256
  38. }
  39. },
  40. layers: [
  41. {
  42. id: 'simple-tiles',
  43. type: 'raster',
  44. source: 'raster-tiles',
  45. minzoom: 0,
  46. maxzoom: 22
  47. }
  48. ]
  49. },
  50. center: [120.143, 30.236], // starting position
  51. zoom: 3 // starting zoom
  52. });
  53. map.addControl(new mapboxgl.NavigationControl(), 'top-left');
  54. map.on('load', function() {
  55. // 设置经纬网
  56. var graticuleLayer = new mapboxgl.supermap.GraticuleLayer();
  57. map.addLayer(graticuleLayer);
  58. });
  59. </script>
  60. </body>
  61. </html>