jQuery-Store-Locator-Plugin
jQuery-Store-Locator-Plugin copied to clipboard
auto zoom out in max distance example
In this example https://bjornblog.com/storelocator/v2/maxdistance-example.html
when search 'MN 55102' within 10 miles it's fine. but if i increase the max distance to 40 miles, the map should zoom out so that all the search results can be seen in the map window. Is there any way to automatically zoom to increase every result?
Ever found a solution for this?
Edit: Found something, but isn't that elegant. You'll need to use the callbackFormVals
which get you the current distance (bh-sl-maxdistance
) set after form submit. You need to set
$("#bh-sl-map-container").storeLocator({
...
callbackFormVals: function(addressInput, searchInput, distance, region) {
var zoom = 14;
if(distance == 40) {
zoom = 6;
}
if(distance == 100) {
zoom = 4;
}
setTimeout(() => { this.map.setZoom(zoom); }, 50);
},
...
});
This is not automatic, but it's the closet I can get to set the zoom level based on the distance.