2018-03-14 22:07:41 +08:00
const _ = require ( 'lodash' )
const leaflet = require ( 'leaflet' )
2018-03-13 06:30:52 +08:00
export default ( opts ) => {
2018-03-14 22:07:41 +08:00
opts = _ . defaults ( opts , {
render _elem : 'map' ,
center : [ 29.98139 , - 95.33374 ] ,
zoom : 5 ,
maxZoom : 10 ,
layers : [ ] ,
set _marker : false ,
} )
2018-03-13 06:30:52 +08:00
2018-03-14 22:07:41 +08:00
let feature _groups = [ ]
/ * v a r o p e n a i p _ a i r s p a c e _ l a b e l s = n e w l e a f l e t . T i l e L a y e r . W M S (
"http://{s}.tile.maps.openaip.net/geowebcache/service/wms" , {
maxZoom : 14 ,
minZoom : 12 ,
layers : 'openaip_approved_airspaces_labels' ,
tileSize : 1024 ,
detectRetina : true ,
subdomains : '12' ,
format : 'image/png' ,
transparent : true
} ) ;
2018-03-13 06:30:52 +08:00
2018-03-14 22:07:41 +08:00
openaip _airspace _labels . addTo ( map ) ; * /
2018-03-13 06:30:52 +08:00
2018-03-14 22:07:41 +08:00
const opencyclemap _phys _osm = new leaflet . TileLayer (
'http://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=f09a38fa87514de4890fc96e7fe8ecb1' , {
maxZoom : 14 ,
minZoom : 4 ,
format : 'image/png' ,
transparent : true
} )
2018-03-13 06:30:52 +08:00
2018-03-14 22:07:41 +08:00
feature _groups . push ( opencyclemap _phys _osm )
2018-03-13 06:30:52 +08:00
2018-03-14 22:07:41 +08:00
/*const openaip_cached_basemap = new leaflet.TileLayer("http:/ / { s } . tile . maps . openaip . net / geowebcache / service / tms / 1.0 . 0 / openaip _basemap @ EPSG % 3 A900913 @ png / { z } / { x } / { y } . png " , {
maxZoom : 14 ,
minZoom : 4 ,
tms : true ,
detectRetina : true ,
subdomains : '12' ,
format : 'image/png' ,
transparent : true
} ) ;
2018-03-13 06:30:52 +08:00
2018-03-14 22:07:41 +08:00
feature _groups . push ( openaip _cached _basemap ) ;
* /
2018-03-13 06:30:52 +08:00
2018-03-14 22:07:41 +08:00
const openaip _basemap _phys _osm = leaflet . featureGroup ( feature _groups )
2018-03-13 06:30:52 +08:00
2018-03-14 22:07:41 +08:00
let map = leaflet . map ( 'map' , {
layers : [ openaip _basemap _phys _osm ] ,
center : opts . center ,
zoom : opts . zoom ,
scrollWheelZoom : false ,
} )
2018-03-13 06:30:52 +08:00
2018-03-14 22:07:41 +08:00
const attrib = leaflet . control . attribution ( { position : 'bottomleft' } )
attrib . addAttribution ( '<a href="https://www.thunderforest.com" target="_blank" style="">Thunderforest</a>' )
attrib . addAttribution ( '<a href="https://www.openaip.net" target="_blank" style="">openAIP</a>' )
attrib . addAttribution ( '<a href="https://www.openstreetmap.org/copyright" target="_blank" style="">OpenStreetMap</a> contributors' )
attrib . addAttribution ( '<a href="https://www.openweathermap.org" target="_blank" style="">OpenWeatherMap</a>' )
2018-03-13 06:30:52 +08:00
2018-03-14 22:07:41 +08:00
attrib . addTo ( map )
2018-03-13 06:30:52 +08:00
2018-03-14 22:07:41 +08:00
return map
2018-03-13 06:30:52 +08:00
} ;