added location marker
This commit is contained in:
parent
6478d95a1a
commit
d8f95d3abd
21
index.html
21
index.html
@ -38,11 +38,30 @@ window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', upd
|
||||
<br>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<a href="https://git.ttnrtsite.me/ssp6904/usmap">View source code</a>
|
||||
<a href="https://git.ttnrtsite.me/ssp6904/usmap" role="button" class="btn btn-primary">View source code</a>
|
||||
<button type="button" class="btn btn-primary" onclick="getLocationLeaflet()">Get location</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function onLocationFound(e) {
|
||||
var location = e.latlng;
|
||||
var marker = L.marker(location);
|
||||
marker.addTo(map);
|
||||
}
|
||||
|
||||
function onLocationError(e) {
|
||||
alert(e.message);
|
||||
}
|
||||
|
||||
function getLocationLeaflet() {
|
||||
map.on('locationfound', onLocationFound);
|
||||
map.on('locationerror', onLocationError);
|
||||
map.locate({
|
||||
setView: true,
|
||||
maxZoom: 10
|
||||
});
|
||||
}
|
||||
var leafletRadarAttribution = '<a href="https://github.com/rwev/leaflet-radar">Radar source code</a>';
|
||||
var osm = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
maxZoom: 19,
|
||||
|
Loading…
Reference in New Issue
Block a user