javascript - leaflet use satellite view, drupal 8? -
i need instead of basic view in leaflet (it's map of world), satellite view, still need able switch between them? how work, can explain me?
installed modules:
without using external plugin :
gpxpod.map = new l.map('map', { zoomcontrol: true }); var osmurl = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; var osmattribution = 'map data © 2013 <a href="http://openstreetmap'+ '.org">openstreetmap</a> contributors'; var osm = new l.tilelayer(osmurl, {maxzoom: 18, attribution: osmattribution}); var esriaerialurl = 'https://server.arcgisonline.com/arcgis/rest/services'+ '/world_imagery/mapserver/tile/{z}/{y}/{x}'; var esriaerialattrib = 'tiles © esri — source: esri, i-cubed, '+ 'usda, usgs, aex, geoeye, getmapping, aerogrid, ign, igp, upr-egp, , the'+ ' gis user community'; var esriaerial = new l.tilelayer(esriaerialurl, {maxzoom: 18, attribution: esriaerialattrib}); var gurl = 'http://mt0.google.com/vt/lyrs=s&x={x}&y={y}&z={z}'; var gattribution = 'google'; var googlesat = new l.tilelayer(gurl, {maxzoom: 18, attribution: gattribution}); var baselayers = { 'openstreetmap': osm, 'esri aerial': esriaerial, 'google map sat': googlesat } l.control.layers(baselayers, {}).addto(map);
this piece of code adds standard control switch between tile provider layers. includes 2 satellite tile providers.
more info : http://leafletjs.com/reference-1.0.3.html#control-layers
Comments
Post a Comment