maps: display location pointer whenever device location is known (#31078)

This commit is contained in:
Frédéric Péters 2019-03-05 09:06:59 +01:00
parent 0e224961b8
commit 08182efe31
1 changed files with 5 additions and 1 deletions

View File

@ -143,8 +143,9 @@ $(function() {
zoomOutTitle: gettext('Zoom out')
}).addTo(map);
}
var gps_control = null;
if (L.Control.Gps && $map_widget.data('include-geoloc-button')) {
var gps_control = new L.Control.Gps({
gps_control = new L.Control.Gps({
position: map_controls_position,
tooltipTitle: gettext('Display my position')});
map.addControl(gps_control);
@ -163,6 +164,9 @@ $(function() {
return;
}
map.setView(e.latlng, map_options.zoom);
if (gps_control) {
gps_control.addLayer();
}
});
map.on('locationerror', function(e) {
$map_widget.removeClass('waiting-for-geolocation');