I am playing around with custom overlays in Google Maps, especially the OverlayView class. I have after much trouble and debugging concluded that there might be an inconsistency when binding the "map" property of the OverlayView (which derives from MVCObject) to other MVC objects.
I am not sure if this is a bug or just me missing something important. I have however set up a test scenario that yields odd results for OverlayView compared to that of MVCObject. The test scenario goes as follows:
var o = new google.maps.MVCObject()
var x = new google.maps.OverlayView();
x.bindTo("map", o);
o.set("map", myMap);
setTimeout(function () { o.set("map", null); }, 500);
setTimeout(function () { alert("Map is null: " + (x.get("map") == null)); }, 1000);
From what I understand after the bindTo call, the "map" property value should propagate between the two objects, when either is changed. However doing a test on this yields "Map is null: false," which contradicts the assumption.
For some reason it only works when delaying the calls through setTimeout, yet what throws me in the direction of it being a bug in OverlayView is that changing the OverlayView type in the test code to a regular MVCObject yields the correct answer. And it seems it's only the "map" property as changing the property name also makes it work.
Any ideas here? Have tested it in multiple browsers and result is the same.