phpvms/resources/js/maps/base_map.js

72 lines
2.1 KiB
JavaScript
Raw Normal View History

const leaflet = require('leaflet');
export default (opts) => {
opts = Object.assign({
2018-03-14 22:07:41 +08:00
render_elem: 'map',
center: [29.98139, -95.33374],
zoom: 5,
maxZoom: 10,
layers: [],
set_marker: false,
}, opts);
let feature_groups = [];
2018-03-14 22:07:41 +08:00
/*var openaip_airspace_labels = new leaflet.TileLayer.WMS(
"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-14 22:07:41 +08:00
openaip_airspace_labels.addTo(map);*/
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-14 22:07:41 +08:00
feature_groups.push(opencyclemap_phys_osm)
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%3A900913@png/{z}/{x}/{y}.png", {
maxZoom: 14,
minZoom: 4,
tms: true,
detectRetina: true,
subdomains: '12',
format: 'image/png',
transparent: true
});
2018-03-14 22:07:41 +08:00
feature_groups.push(openaip_cached_basemap);
*/
2018-03-14 22:07:41 +08:00
const openaip_basemap_phys_osm = leaflet.featureGroup(feature_groups)
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-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-14 22:07:41 +08:00
attrib.addTo(map)
2018-03-14 22:07:41 +08:00
return map
};