add geolocation
This commit is contained in:
parent
bdda5c11a7
commit
71d93f7e3d
10
index.html
10
index.html
@ -137,6 +137,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function loadMap(data) {
|
function loadMap(data) {
|
||||||
|
var geolocate = new mapboxgl.GeolocateControl();
|
||||||
|
|
||||||
var points = [];
|
var points = [];
|
||||||
$.each(data, function(key, value) {
|
$.each(data, function(key, value) {
|
||||||
points.push({
|
points.push({
|
||||||
@ -167,6 +169,7 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
map.addControl(new mapboxgl.NavigationControl(), 'top-left');
|
map.addControl(new mapboxgl.NavigationControl(), 'top-left');
|
||||||
|
map.addControl(geolocate, 'top-right');
|
||||||
});
|
});
|
||||||
|
|
||||||
map.on('click', function (e) {
|
map.on('click', function (e) {
|
||||||
@ -190,6 +193,13 @@
|
|||||||
map.getCanvas().style.cursor = features.length ? 'pointer' : '';
|
map.getCanvas().style.cursor = features.length ? 'pointer' : '';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
geolocate.on('geolocate', function (e) {
|
||||||
|
map.setZoom(14);
|
||||||
|
popup.setLngLat([e.coords.longitude, e.coords.latitude])
|
||||||
|
.setHTML('Current Location')
|
||||||
|
.addTo(map);
|
||||||
|
})
|
||||||
|
|
||||||
var template = $('#Table').html();
|
var template = $('#Table').html();
|
||||||
var rendered = Mustache.render(template, {rows: data});
|
var rendered = Mustache.render(template, {rows: data});
|
||||||
$('#Stores').html(rendered);
|
$('#Stores').html(rendered);
|
||||||
|
Loading…
Reference in New Issue
Block a user