bjorn2404 / jQuery-Store-Locator-Plugin

A store locator plugin using Google Maps API version 3
MIT License
493 stars 235 forks source link

Distance/Radius not working correctly #234

Open user00265 opened 6 years ago

user00265 commented 6 years ago

I've been trying to get distance limits to cooperate with little to no success.

Using the autogeocode-example.html as a basis, I added the following two pieces to get the data I needed flowing:

<select id="bl-sl-maxradius" name="bl-sl-maxradius">
 <option value="60">60 Miles</option>
 <option value="20">20 Miles</option>
 <option value="30">30 Miles</option>
 <option value="40">40 Miles</option>
 <option value="50">50 Miles</option>
</select>
jQuery(function(){
    jQuery('#bh-sl-map-container').storeLocator({
        dataType: 'json',
        dataLocation: 'dealers.php',
        autoGeocode: true,
        pagination: true,
        featuredLocations: true,
        sessionStorage: true,
        ajaxData:{
            'circle': jQuery('#bl-sl-maxradius').val()
        },
        catMarkers: {
            'Preferred' : ['assets/img/gold-marker.png', 32, 32],
            'Dealer': ['assets/img/blue-marker.png', 32, 32]
        }
    });
});

I know that the maxDistance is not set, but even with that I had no success whatsoever. I added circle to debug the database query, and to trigger a distance formula from David Simpson which was working marvelously on a previous iteration of the project. I defaulted the search radius to 60 miles because the form being destroyed and reset before the ajaxData code gets the data breaks it and only picks up the default/first value.

The radius bounds, interestingly enough when calculated via the boundaries, never seems to change. In miles, when selecting 30 mile radius, it would calculate as 12 miles and change. Then I figured out it didn't matter what I was sending, it was always the same radius displayed. I made the ajaxData change to get more data to come out of the server, to see if that was the issue, but even if the data is provided, it seems to be ignored by the interface and the same radius is applied.

I pulled one zip code that is right next to several others, but it only pulled data from within that zip code in a very weird way. I pulled an adjacent zip code and the diamond pulled data right next to other data points in the radius.

Now, all this being said, due to the nature of some of the data, I can't post it publicly, but I can share it privately to get it all inspected. My email on my profile works!