leaflet:改造繼承L.TileLayer類適配arcgis切片地圖
阿新 • • 發佈:2018-10-01
all span class call pre 地圖 color services geo
1、繼承L.TileLayer的新類arcgisTiledLayer
L.TileLayer.ArcgisTiledLayer = L.TileLayer.extend({ initialize: function (url, options) { L.TileLayer.prototype.initialize.call(this, url + "/tile/{z}/{y}/{x}", options); } }); L.tileLayer.arcgisTiledLayer = function (url, options) {return new L.TileLayer.ArcgisTiledLayer(url, options); };
2、前端調用方法
var layer1 = L.tileLayer.arcgisTiledLayer(‘http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer‘, { maxZoom: 12, minZoom: 4 }); var map = L.map("map", { center: [31.59, 120.29], zoom: 5, layers: [layer1], zoomControl:false });
leaflet:改造繼承L.TileLayer類適配arcgis切片地圖