Closed augustbend closed 8 years ago
@bjorn2404 Thank you for such an outstanding library! It really is the bees' knees.
I'm experiencing a similar issue and I've put my code on a temp server so you can see what I'm working with: https://goo.gl/GIObpM. I would appreciate any help on this issue.
This is how I'm calling the library:
if('undefined' !== typeof(local)) {
$('#bh-sl-map-container').storeLocator({
'autoComplete': true,
'dataRaw': local.locations,
'fullMapStart': true,
'infowindowTemplatePath': local.theme_dir + '/templates/locations/infowindow-description.html',
'listTemplatePath': local.theme_dir + '/templates/locations/location-list-description.html',
'maxDistance': true,
'mapSettings': {
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP,
scrollwheel: false
},
'querystringParams': true,
'slideMap': false
});
}
The locations
referenced is a localized JSON object containing all the markers.
The unexpected behavior occurs when a search from my home page includes a ZIP without any markers. Visitors arrive on the results page with the correct query string parameters but the map never displays, no error pops up, and a console error displays Uncaught Error: No locations found. Please check the dataLocation setting and path.
Removing maxDistance
from my JS leads to no more errors and actually exhibits the behavior I want when a ZIP with nor markers is searched on my home page—that is, the error popup displays and all markers display on the map. The obvious downside with this fix is that the distance radius is ignored.
Quick breakdown:
maxDistance
querystringParams
and hidden <input>
setting bh-sl-maxdistance
= 60maxDistance
maxDistance
querystringParams
and hidden <input>
setting bh-sl-maxdistance
= 60 and maxDistance: true
Uncaught Error: No locations found. Please check the dataLocation setting and path.
; all searches fail after this first failure.My server is setup with maxDistance: true
to replicate the error.
Thank you for any help with this!
This is looking like a one line fix. If you need an immediate fix: search for the "Check the closest marker" comment change the second line after that from:
if (_this.settings.maxDistance === true && firstRun !== true && maxDistance) {
to:
if (_this.settings.maxDistance === true && maxDistance) {
I've implemented this fix in v2.7.0. Let me know if either of you are still running into it. Thanks
@bjorn2404 I face the same issue when I give fullmapstart as true and i have empty json file. Is there a way where i can show the map without any pins when the stores json is empty?
I have created this sample for you to test:
UC 1: Using a search from outside the map page