I have a collection of locations on a google map object, stored in a Backbone collection:
var Location = Backbone.Model.extend({
defaults: {
latitute: "",
longitude: "",
visited: false;
},
});
var LocationCollection = Backbone.Collection.extend({
model: Location,
url: 'api/locations'
});
As each point is clicked on the map, the location model property 'visited' is set to true.
The original collection of locations comes from the database (based on the bounds of the map), which does not store any 'visited' information, simply a list of locations within range.
When the user changes the bounds of the Google map, by moving around, zooming in/out etc, I need to retrieve a brand new list of locations within the new parameters, then somehow assimilate this list with the existing collection, adding new locations, but retaining the visited properties for existing ones?
I hope this isn't too vague, but where to start?? Is there a way with jQuery to map complex objects from one collection to another? Or would it make more sense to split the collections, sending visited information back to the server and combine them there? Or will the Backbone collection remember 'visited' values and only update those in the collection with new properties?
Sorry, I thought I knew this stuff, but I have never ever done anything like this.