The leaflet documentation tells me that you should use the maxZoom option on location but it's not working (http://leafletjs.com/reference.html#map-locate-options). When a user is using geolocation on my site and finds their position at the map it zooms in too much and I want to regulate this myself. Does anyone have a quick fix?
Asked
Active
Viewed 1,148 times
0
-
1Can you post your site link? to check? – Thennarasan Jul 25 '16 at 09:36
-
@Thennarasan https://dabauto.no/verksteder – J. Sveum Jul 25 '16 at 11:09
-
In your main.js file there is a line ` var map = L.mapbox.map('map', 'mapbox.light').setView([63.51338, 15.03236], 5);` the last parameter `5` is that hardcoded? if so please change the level of you want and check. – Thennarasan Jul 25 '16 at 12:15
-
@Thennarasan yes it's hardcoded. I don't need to change that one, only the zoom when I'm using geolocation.. – J. Sveum Jul 25 '16 at 13:03
-
Hope that is what you have to modify to regulate the zoom when someone using the geolocation. – Thennarasan Jul 25 '16 at 13:17
1 Answers
0
in your main.js you have to set a locate option in this section
if (!navigator.geolocation) {
geolocate.innerHTML = 'Geolocation is not available';
} else {
geolocate.onclick = function (e) {
var tl = new TimelineMax({repeat:2});
tl.to("svg.pointwhite", .10, {transformOrigin: "50% 100%", scaleY:0.25, yoyo:true, repeat:1})
.to("svg.pointwhite", .65, {y:-6, ease:Circ.easeOut, yoyo:true, repeat:1});
e.preventDefault();
e.stopPropagation();
map.locate({ maxZoom: 12}); // locate option goes here
};
}

YaFred
- 9,698
- 3
- 28
- 40