How to set different zoom levels in layers on a map using flyers.

How to set different zoom levels in layers on a map. I need to show different zoom levels in different layers. For example, I have 2 layers 1.city, 2.state. When the map initialization level is 18, but when I show the STATE level, I have to set the zoom level to 22.

I am using the code below.

var city = new L.LayerGroup(); var state = new L.LayerGroup(); var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png', cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18}), map = new L.Map('map', {layers: [cloudmade,city,state], center: new L.LatLng(17.7003292, 82.01161768), zoom:18 }); 

How to set the zoom level when initializing a layer?

+4
source share
1 answer

Here's a jsfiddle example of how to do this.

 var map = new L.Map('amap', { center: new L.LatLng(45.50144, -122.67599), zoom: 4, minZoom: 0, maxZoom: 18, layers: [ L.tileLayer('http://{s}.tile.cloudmade.com/{key}/997/256/{z}/{x}/{y}.png', { maxZoom: 13, minZoom: 0, attribution: 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade', key: 'BC9A493B41014CAABB98F0471D759707' }), L.tileLayer('http://server.arcgisonline.com/ArcGIS/' + 'rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', { minZoom: 14, maxZoom: 18, attribution: 'Tiles © Esri — ' + 'Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, ' + 'Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'}) ]}); 
+4
source

Source: https://habr.com/ru/post/1479095/


All Articles