Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
daarisameen authored Jan 23, 2023
1 parent 455b643 commit 4e1146d
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,31 +84,30 @@ function showPosition(position) {

$("#map").attr("hidden",false);

var map = L.map('map').setView([x1, y1], 13);
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
var marker = L.marker([x1, y1]).addTo(map);
var circle = L.circle([x1, y1], {
color: 'red',
fillColor: '#f03',
fillOpacity: 0.5,
radius: 1000
}).addTo(map);

marker.bindPopup("<b>You are here</b>").openPopup();
circle.bindPopup("approximate location");
var popup = L.popup();

function onMapClick(e) {
popup
.setLatLng(e.latlng)
.setContent("You clicked the map at " + e.latlng.toString())
.openOn(map);
}
var map = L.map('map').fitWorld();

L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© OpenStreetMap'
}).addTo(map);

map.locate({setView: true, maxZoom: 16});

function onLocationFound(e) {
var radius = e.accuracy;

L.marker(e.latlng).addTo(map)
.bindPopup("You are within " + radius + " meters from this point").openPopup();

L.circle(e.latlng, radius).addTo(map);
}

map.on('locationfound', onLocationFound);
function onLocationError(e) {
alert(e.message);
}

map.on('click', onMapClick);
map.on('locationerror', onLocationError);



Expand Down

0 comments on commit 4e1146d

Please sign in to comment.