2020-05-16 16:42:19 +00:00
|
|
|
var mymap;
|
2020-05-17 15:30:23 +00:00
|
|
|
var poi_layer;
|
2020-05-16 16:42:19 +00:00
|
|
|
|
|
|
|
$( document ).ready(function() {
|
|
|
|
// Differents layers for the map
|
2021-03-29 21:33:49 +00:00
|
|
|
var topo_maptiler = L.tileLayer('https://api.maptiler.com/maps/topographique/{z}/{x}/{y}.png?key=Sm8M7mJ53GtYdl773rpi', {tms: false, attribution: 'Carte © <a href="https://www.maptiler.com/copyright/" target="_blank">MapTiler</a>, Données © <a href="http://www.openstreetmap.org/copyright" target="_blank">Contributeurs OpenStreetMap</a>', tileSize: 512, zoomOffset: -1, minZoom: 1});
|
2021-03-29 21:48:13 +00:00
|
|
|
var ign = L.tileLayer('https://wxs.ign.fr/5sf7ych7ecsa575btea2ln17/geoportail/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=ORTHOIMAGERY.ORTHOPHOTOS&format=image/jpeg&style=normal', {attribution: 'Carte & Connées © <a href="http://ign.fr/" target="_blank">IGN-F/Géoportail</a>'});
|
2020-05-16 16:42:19 +00:00
|
|
|
// Base layers
|
|
|
|
var baseLayers = {
|
2021-03-29 21:33:49 +00:00
|
|
|
"OpenStreetMap": topo_maptiler,
|
|
|
|
"IGN France": ign
|
2020-05-16 16:42:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
mymap = L.map('mapid', {
|
|
|
|
zoomControl: false,
|
2021-03-27 17:39:39 +00:00
|
|
|
layers: [topo_maptiler]
|
|
|
|
}).setView([47, 3], 6);
|
|
|
|
$("#map-credits").html(topo_maptiler.getAttribution());
|
2020-05-16 16:42:19 +00:00
|
|
|
|
|
|
|
L.control.scale({
|
|
|
|
position: "bottomleft",
|
|
|
|
imperial: false
|
|
|
|
}).addTo(mymap);
|
|
|
|
|
|
|
|
L.control.fullscreen({
|
|
|
|
position: "bottomleft"
|
|
|
|
}).addTo(mymap);
|
|
|
|
|
|
|
|
L.control.zoom({
|
|
|
|
zoomOutText: "<i class=\"fa fa-minus\" aria-hidden=\"true\"></i>",
|
|
|
|
zoomInText: "<i class=\"fa fa-plus\" aria-hidden=\"true\"></i>",
|
|
|
|
position: "bottomleft"
|
|
|
|
}).addTo(mymap);
|
|
|
|
|
|
|
|
L.control.layers(baseLayers,null,{
|
|
|
|
position: "bottomright"
|
|
|
|
}).addTo(mymap);
|
|
|
|
|
|
|
|
mymap.removeControl(mymap.attributionControl);
|
|
|
|
|
|
|
|
mymap.on('baselayerchange', function(e) {
|
|
|
|
$("#map-credits").html(e.layer.getAttribution());
|
|
|
|
});
|
2020-05-17 15:30:23 +00:00
|
|
|
|
2021-03-27 17:39:39 +00:00
|
|
|
poi_layer = L.marker([47, 3], {draggable: true}).addTo(mymap);
|
2021-03-29 21:19:49 +00:00
|
|
|
poi_layer.bindTooltip("Glissez moi au bon endroit.", {permanent: true, direction: 'auto'}).openTooltip();
|
2020-05-17 15:30:23 +00:00
|
|
|
|
|
|
|
mymap.on('click', function(e){
|
2020-05-18 05:58:23 +00:00
|
|
|
poi_layer.unbindTooltip();
|
2020-05-17 15:30:23 +00:00
|
|
|
poi_layer.setLatLng(e.latlng);
|
2021-05-19 18:34:02 +00:00
|
|
|
$("#lat").val(e.latlng.lat.toFixed(6));
|
|
|
|
$("#lon").val(e.latlng.lng.toFixed(6));
|
2020-05-17 15:30:23 +00:00
|
|
|
})
|
|
|
|
poi_layer.on('move', function(e){
|
2020-05-18 05:58:23 +00:00
|
|
|
poi_layer.unbindTooltip();
|
2021-05-19 18:34:02 +00:00
|
|
|
$("#lat").val(e.latlng.lat.toFixed(6));
|
|
|
|
$("#lon").val(e.latlng.lng.toFixed(6));
|
2020-05-17 15:30:23 +00:00
|
|
|
})
|
2020-05-18 05:34:26 +00:00
|
|
|
|
|
|
|
var poiicon = L.icon({
|
|
|
|
iconSize: [24, 24],
|
|
|
|
iconAnchor: [12, 12]
|
|
|
|
});
|
|
|
|
$("#type_selector label").click(function(e) {
|
2020-05-18 05:58:23 +00:00
|
|
|
poi_layer.unbindTooltip();
|
2020-05-18 05:34:26 +00:00
|
|
|
poiicon.options.iconUrl = e.currentTarget.firstChild.currentSrc;
|
|
|
|
poi_layer.setIcon(poiicon);
|
|
|
|
})
|
2020-05-17 15:30:23 +00:00
|
|
|
});
|