<div id="map"></div> <script> var map = L.map("map", { center: [39.904983,116.427287], zoom: 3, zoomControl: false }).setMaxBounds([[-90,0],[90,360]]); var mapLayers = { '谷歌高德杂交/卫星':L.layerGroup([ L.tileLayer('//www.google.cn/maps/vt?lyrs=s@189&gl=cn&x={x}&y={y}&z={z}', { maxZoom: 20, minZoom: 3, attribution: "谷歌提供卫星图,高德提供街道图" }), L.tileLayer('//webst0{s}.is.autonavi.com/appmaptile?style=8&x={x}&y={y}&z={z}', { maxZoom: 20, maxNativeZoom: 18, minZoom: 3, attribution: "谷歌提供卫星图,高德提供街道图", subdomains: "1234", opacity:0.5 }) ]).addTo(map), '高德/卫星':L.layerGroup([ L.tileLayer('//webst0{s}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}', { maxZoom: 20, maxNativeZoom: 18, minZoom: 3, attribution: "高德地图 AutoNavi.com", subdomains: "1234" }), L.tileLayer('//webst0{s}.is.autonavi.com/appmaptile?style=8&x={x}&y={y}&z={z}', { maxZoom: 20, maxNativeZoom: 18, minZoom: 3, attribution: "高德地图 AutoNavi.com", subdomains: "1234", opacity:0.5 }) ]), '高德/街道':L.tileLayer('//webrd0{s}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}', { maxZoom: 20, maxNativeZoom: 18, minZoom: 3, attribution: "高德地图 AutoNavi.com", subdomains: "1234" }), '谷歌/卫星':L.tileLayer('//www.google.cn/maps/vt?lyrs=s@189&gl=cn&x={x}&y={y}&z={z}', { maxZoom: 20, minZoom: 3, attribution: "谷歌 Google.cn" }), '谷歌/街道':L.tileLayer('//www.google.cn/maps/vt?lyrs=m@189&gl=cn&x={x}&y={y}&z={z}', { maxZoom: 20, minZoom: 3, attribution: "谷歌 Google.cn" }), '智图/街道':L.tileLayer('//map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetPurplishBlue/MapServer/tile/{z}/{y}/{x}', { maxZoom: 20, maxNativeZoom: 16, minZoom: 3, attribution: "智图 GeoQ.cn" }) } var layerControl = L.control.layers(mapLayers, {}, { position: 'topright', collapsed: true }).addTo(map); L.control.zoom({ zoomInTitle: '放大', zoomOutTitle: '缩小' }).addTo(map); </script>
在 Leaflet 中合并使用谷歌中国卫星图和高德地图
最新推荐文章于 2024-04-28 15:21:18 发布