add geolocation

This commit is contained in:
David 2017-03-26 22:57:03 -04:00
parent bdda5c11a7
commit 71d93f7e3d
1 changed files with 10 additions and 0 deletions

View File

@ -137,6 +137,8 @@
}
function loadMap(data) {
var geolocate = new mapboxgl.GeolocateControl();
var points = [];
$.each(data, function(key, value) {
points.push({
@ -167,6 +169,7 @@
}
})
map.addControl(new mapboxgl.NavigationControl(), 'top-left');
map.addControl(geolocate, 'top-right');
});
map.on('click', function (e) {
@ -190,6 +193,13 @@
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 rendered = Mustache.render(template, {rows: data});
$('#Stores').html(rendered);