2018-05-15 03:14:27 +08:00
//
2018-03-28 07:18:25 +08:00
const leaflet = require ( 'leaflet' ) ;
2018-05-15 03:14:27 +08:00
require ( 'leaflet-providers' ) ;
2018-03-13 06:30:52 +08:00
export default ( opts ) => {
2018-05-03 04:14:18 +08:00
opts = Object . assign ( {
render _elem : 'map' ,
center : [ 29.98139 , - 95.33374 ] ,
zoom : 5 ,
maxZoom : 10 ,
layers : [ ] ,
set _marker : false ,
2018-05-15 03:17:47 +08:00
providers : [
'Esri.WorldStreetMap' ,
] ,
tile _layers : [ ] ,
2018-05-03 04:14:18 +08:00
} , opts ) ;
2018-03-13 06:30:52 +08:00
2018-05-15 03:14:27 +08:00
/ *
2018-05-03 04:14:18 +08:00
let feature _groups = [ ] ;
2018-05-15 03:14:27 +08:00
const openaip _airspace _labels = new leaflet . TileLayer . WMS (
2018-05-03 04:14:18 +08:00
"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-05-03 04:14:18 +08:00
openaip _airspace _labels . addTo ( map ) ; * /
2018-03-13 06:30:52 +08:00
2018-05-03 04:14:18 +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-05-03 04:14:18 +08:00
feature _groups . push ( openaip _cached _basemap ) ;
* /
2018-03-13 06:30:52 +08:00
2018-05-03 04:14:18 +08:00
let map = leaflet . map ( 'map' , {
2018-05-15 03:14:27 +08:00
//layers: [openaip_basemap_phys_osm],
2018-05-03 04:14:18 +08:00
center : opts . center ,
zoom : opts . zoom ,
scrollWheelZoom : false ,
} ) ;
2018-03-13 06:30:52 +08:00
2018-05-15 03:17:47 +08:00
for ( const i in opts . providers ) {
leaflet . tileLayer . provider ( opts . providers [ i ] ) . addTo ( map ) ;
}
2018-03-13 06:30:52 +08:00
2018-05-15 03:14:27 +08:00
return map ;
2018-03-13 06:30:52 +08:00
} ;