I have this code
<code> var map = L.map('map').setView([51.505, -0.09], 5);
var marker = new L.Marker([100,20], {draggable:false});
L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}', {
attribution: 'Tiles © Esri — Source: Esri',
maxZoom: 13
}).addTo("map")
function onMapClick(e) {
marker.setLatLng(e.latlng);
document.getElementById('lat').value = e.latLng.lat();
document.getElementById('long').value = e.latLng.lng();
};
marker.addTo('map')
map.on('click', onMapClick);
</code>
<code> var map = L.map('map').setView([51.505, -0.09], 5);
var marker = new L.Marker([100,20], {draggable:false});
L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}', {
attribution: 'Tiles © Esri — Source: Esri',
maxZoom: 13
}).addTo("map")
function onMapClick(e) {
marker.setLatLng(e.latlng);
document.getElementById('lat').value = e.latLng.lat();
document.getElementById('long').value = e.latLng.lng();
};
marker.addTo('map')
map.on('click', onMapClick);
</code>
var map = L.map('map').setView([51.505, -0.09], 5);
var marker = new L.Marker([100,20], {draggable:false});
L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}', {
attribution: 'Tiles © Esri — Source: Esri',
maxZoom: 13
}).addTo("map")
function onMapClick(e) {
marker.setLatLng(e.latlng);
document.getElementById('lat').value = e.latLng.lat();
document.getElementById('long').value = e.latLng.lng();
};
marker.addTo('map')
map.on('click', onMapClick);
And it keeps on give T.addLayer is not defined so the map doesn’t load, could you help me. Thank you
New contributor
Carlos Brewer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.