Skip to content

Instantly share code, notes, and snippets.

@jmcelroy5
Last active August 29, 2015 14:10
Show Gist options
  • Save jmcelroy5/5310653aa393f6531e63 to your computer and use it in GitHub Desktop.
Save jmcelroy5/5310653aa393f6531e63 to your computer and use it in GitHub Desktop.
Change map marker color when listing is clicked
Map.prototype.toggleMarkerColor = function(listingId){ // this is not running
alert("The map heard the click event!");
var idx = this.markerMap[listingId];
this.geoJson[idx].properties["marker-color"] = "#ffffff";
this.markerLayer.setGeoJson(this.geoJson);
this.markerLayer.addTo(this.map);
};
// Under Listings view...
$("li.listing-link").on('click', function(){
var listingId = $(this).data('id');
Map.toggleMarkerColor(listingId); // Uncaught TypeError: undefined is not a function
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment