Organization html

From Redazione
Revision as of 13:05, 28 February 2020 by Luca.speziale (talk | contribs)
Jump to navigation Jump to search

Organization
var mapCenter = [22, 87]; var map = L.map('map', {center : mapCenter, zoom : 3}); L.tileLayer('https://{s}.tiles.mapbox.com/v3/{id}/{z}/{x}/{y}.png', { maxZoom: 18, attribution: 'Map data © OpenStreetMap contributors, ' + 'CC-BY-SA, ' + 'Imagery © Mapbox', id: 'examples.map-i875mjb7', noWrap : true }).addTo(map); var marker = L.marker(mapCenter).addTo(map); var updateMarker = function(lat, lng) { marker .setLatLng([lat, lng]) .bindPopup("Your location : " + marker.getLatLng().toString()) .openPopup(); return false; }; map.on('click', function(e) { $('#latInput').val(e.latlng.lat); $('#lngInput').val(e.latlng.lng); updateMarker(e.latlng.lat, e.latlng.lng); }); var updateMarkerByInputs = function() { return updateMarker( $('#latInput').val() , $('#lngInput').val()); } $('#latInput').on('input', updateMarkerByInputs); $('#lngInput').on('input', updateMarkerByInputs);