I am having trouble adding markers to a google map with backbone.
I created a jsfiddle for easier debugging…
I think that the problem might have to do with the posts collection being empty when the map is rendered, but I am not sure.
I have an API that returns posts information, and each post has a latitude and longitude.
Your first issue is that your API (appears to be using TastyPie) returns the array of results not as the root of the response, but as a sub-property.
Backbone Collections expect to receive an array of objects:
Your API returns:
The way to deal with that in Backbone Collections is to override the
parsefunction so that it returns an array of objects:The possible 2nd issue is that when a Collection.fetch() completes, the event it emits is not a
changeevent, but aresetevent. So, if you want your view to re-render when the fetch completes, you need to bind toresetnotchange.