Skip to content

Commit

Permalink
Display only the store on the map
Browse files Browse the repository at this point in the history
A new paramater "storeOnMap" which is false by default. If true, two
event listeners are added and the the list will be refreshed to display
only the store of which the marker is on the map.
  • Loading branch information
jacquesletesson committed Sep 25, 2013
1 parent dbdc05d commit 2e707fe
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions js/jquery.storelocator.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ $.fn.storeLocator = function(options) {
'pinTextColor': '000000',
'lengthUnit': 'm',
'storeLimit': 26,
'storeOnMap': false,
'distanceAlert': 60,
'dataType': 'xml',
'dataLocation': 'locations.xml',
Expand Down Expand Up @@ -795,6 +796,33 @@ $.fn.storeLocator = function(options) {

}

if(settings.storeOnMap === 'true'){
// Add event listener for center change
google.maps.event.addListener(map, 'center_changed', function() {
checkVisibleMarker();
});

// Add event listener for zoom change
google.maps.event.addListener(map, 'zoom_changed', function() {
checkVisibleMarker();
});

function checkVisibleMarker(){
$("#" + settings.listDiv + ' ul').empty();
$(markers).each(function(x, marker){
if(map.getBounds().contains(marker.getPosition()))
{
//Define the location data
locations = define_location_data(marker);
//Set up the list template with the location data
listHtml = listTemplate(locations);
//console.log(listHtml);
$('#' + settings.listDiv + ' ul').append(listHtml);
}
})
}
}

});
}
});
Expand Down

0 comments on commit 2e707fe

Please sign in to comment.