I’m working with Google Maps API v3 and I have an array of markers (markersArray) that each contain an element named ‘id’. Via Ajax, I hit a db and return current ID values as an array (tokID) and call a ‘loadMarkers’ function.
In the ‘loadMarkers’ function I need to remove any array items that don’t match the ID values returned from the db. I’ve looked into .splice() and .filter() but can’t for the life of me get it working.
Sorry for no code sample. I’m really stumped and don’t really have anything to go off of.
Thx!
Mike
Roughly you can do something like this,
UPDATED WORKING CODE
Modify the above code to suit your need.
$.map $.inArray
Check the Working Fiddle
Final Code to find out the Extra ID’s sent from server too is : Fiddle