Markers don't reset when sorting

Permalink Browser Info Environment
I was wondering if there was a way to get the markers on the map to reset and show only the locations that the form is sorted on.

For example, this particular company has five subsidiaries, we want to be able to sort results by the subsidiary and have the markers on the map show only those locations. Currently, the map shows all of the markers regardless.

You can view the site here -http://www.corporateprdev.com/udg/locations/dealer-test...

Type: Discussion
Status: New
FatTony1952
View Replies: View Best Answer
mkly replied on at Permalink Reply
mkly
Hello,
I'm getting a not found on the link you posted.

Best Wishes,
Mike
FatTony1952 replied on at Permalink Reply
FatTony1952
Sorry, I'm so used to typing addresses with pretty URLs and I haven't implemented them yet.

http://www.corporateprdev.com/udg/index.php/locations/dealer-test...
FatTony1952 replied on at Permalink Reply
FatTony1952
Although I have found a script that will clear all markers on the map. I just haven't had the chance to give it a try yet.
mkly replied on at Permalink Reply
mkly
Ok I have it now. Could you give me a Zip Code/Location to get in the general area or the locations that have been added?

Best Wishes,
Mike
FatTony1952 replied on at Permalink Reply
FatTony1952
They're all over North America, but I've been using 250 for the radius and 37620 for the zip.
FatTony1952 replied on at Permalink Reply
FatTony1952
I'm thinking of putting something like this in just before the search function on the click so that the markers clear before the search happens

function clearOverlays() {
  if (markersArray) {
    for (i in markersArray) {
      markersArray[i].setMap(null);
    }
  }
}
mkly replied on at Permalink Best Answer Reply
mkly
Hello,
Indeed, one of the issues was that Dealer Locator is that it was designed to try and allow multiple blocks per page

That said, I worked out a fix and hopefully we'll get this pushed out in an update soon.

If you go to the file
/dealer_locator/block/dealer_search/view.php

After line #10 where it has
var openInfoWindow<?php   echo $controller->bID?>;

Add
var markers<?php echo $controller->bID?> = [];


Then just after (around line #70-ish) where there is
$.getJSON(searchUrl, function(data) {

Add right below that
while(markers<?php echo $controller->bID?>.length > 0) {
  markers<?php echo $controller->bID?>.pop().setMap(null);
}


And then lastly above(Line #120-ish) above
google.maps.event.addListener(marker, 'click', function() {

add
markers<?php echo $controller->bID?>.push(marker);


Hopefully that makes sense. If you have some trouble let me know.

Basically, we're are clearing those markers.

Best Wishes,
Mike
FatTony1952 replied on at Permalink Reply
FatTony1952
Perfect! Thanks mkly!
2excelprogrammer replied on at Permalink Reply
2excelprogrammer
Perfect Answer...!!!!

Thanks a lot mkly.

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.