phpvms/resources/js/maps/base_map.js

63 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-05-15 03:14:27 +08:00
//
const leaflet = require('leaflet');
2018-05-15 03:14:27 +08:00
require('leaflet-providers');
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-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-05-03 04:14:18 +08:00
openaip_airspace_labels.addTo(map);*/
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%3A900913@png/{z}/{x}/{y}.png", {
maxZoom: 14,
minZoom: 4,
tms: true,
detectRetina: true,
subdomains: '12',
format: 'image/png',
transparent: true
});
2018-05-03 04:14:18 +08:00
feature_groups.push(openaip_cached_basemap);
*/
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-05-15 03:17:47 +08:00
for(const i in opts.providers) {
leaflet.tileLayer.provider(opts.providers[i]).addTo(map);
}
2018-05-15 03:14:27 +08:00
return map;
};