Closed Lordnibbler closed 11 years ago
A "change:lat" and "change:lng" event should fire on the MarkerView's model when the location changes. You could bind that event to a method that sets the position of the gOverlay object.
The Backbone.GoogleMaps library should be updated to bind changes in a Location to a MarkerView. It would look something like...
In the MarkerView
constructor: function(){
// ...
this.model.on("change", this.refreshOverlay, this);
// ...
}
// ...
refreshOverlay: function() {
this.gOverlay.setOptions({
position: this.model.getLatlng(),
// ...other overlay options...
});
}
I don't have a lot of time to mess around with this right now, but if you'd like to submit a pull request, I'll take a look at it.
When adding a new "location" in my application, my server-side app asynchronously geocodes the address with longitude and latitude, and then fires a change:lat listener. As such, the markerview gets added somewhere out in Africa.
Right now, there's no way to refresh a single markerview's position on the map, so I'm forced to .addChild() the same location a second time to the map, which produces undesirable behavior.
Can we set up a way to refresh any single markerview's position on the map whenever longitude or latitude change?