|
| 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 data-i18n="resources.title_mvt_mapboxgl"></title> |
| 9 | + <style> |
| 10 | + .leaflet-gl-layer.mapboxgl-map { |
| 11 | + z-index: 1; |
| 12 | + } |
| 13 | + </style> |
| 14 | + <script type="text/javascript" src="../js/include-web.js"></script> |
| 15 | + </head> |
| 16 | + |
| 17 | + <body style="margin: 0; overflow: hidden; background: #fff; width: 100%; height: 100%; position: absolute; top: 0"> |
| 18 | + <div id="map" style="margin: 0 auto; width: 100%; height: 100%"></div> |
| 19 | + <!-- 叠加非3857的地图,请使用mapbox-gl-enhance --> |
| 20 | + <script |
| 21 | + type="text/javascript" |
| 22 | + include="mapbox-gl-enhance" |
| 23 | + src="../../dist/mapboxgl/include-mapboxgl.js" |
| 24 | + ></script> |
| 25 | + <!-- 需引入三方插件 mapbox-gl-leaflet https://github.com/mapbox/mapbox-gl-leaflet --> |
| 26 | + <script type="text/javascript" include="leaflet-mapbox-gl" src="../../dist/leaflet/include-leaflet.js"></script> |
| 27 | + |
| 28 | + <script type="text/javascript"> |
| 29 | + var host = window.isLocal ? window.server : 'https://iserver.supermap.io'; |
| 30 | + var url = host + '/iserver/services/map-china400/rest/maps/China_4326'; |
| 31 | + |
| 32 | + // 为与mapboxgl的级别相匹配,leaflet的分辨率应设置为第0级为全球范围宽度除以瓦片宽度256. |
| 33 | + // 常见坐标系第0级分辨率 WebMercator(3857):2*6378137*Math.PI/256 WGS84(4326):360.0/256 China2000(4490):360.0/256 Beijing54(4214):360.0/256 Xian80(4610):360.0/256 |
| 34 | + var topResolution = 360.0 / 256; |
| 35 | + var resolutions = []; |
| 36 | + for (var zoom = 0; zoom < 22; zoom++) { |
| 37 | + resolutions.push(topResolution / Math.pow(2, zoom)); |
| 38 | + } |
| 39 | + var crs = L.Proj.CRS('EPSG:4326', { |
| 40 | + origin: [-180, 90], |
| 41 | + resolutions: resolutions |
| 42 | + }); |
| 43 | + var map = L.map('map', { |
| 44 | + center: [37.71194458007813, -122.24143981933594], |
| 45 | + zoom: 11, |
| 46 | + crs: crs |
| 47 | + }); |
| 48 | + L.supermap.tiledMapLayer(url).addTo(map); |
| 49 | + $.get( |
| 50 | + host + |
| 51 | + '/iserver/services/map-mvt-California/rest/maps/California/tileFeature/vectorstyles.json?type=MapBox_GL&styleonly=true&tileURLTemplate=ZXY', |
| 52 | + function (style) { |
| 53 | + style.layers[0].paint['background-color'] = 'rgba(168,209,221,0)'; |
| 54 | + var gl = L.mapboxGL({ |
| 55 | + renderWorldCopies: false, |
| 56 | + style: style, |
| 57 | + crs: 'EPSG:4326' |
| 58 | + }).addTo(map); |
| 59 | + // 获取 mapboxgl 地图 |
| 60 | + // var mapboxglMap = gl.getMapboxMap(); |
| 61 | + } |
| 62 | + ); |
| 63 | + </script> |
| 64 | + </body> |
| 65 | +</html> |
0 commit comments