So, I'm trying to expand the google map class, specifically google.maps.OverlayView (in version 3). Executing this vanilla js method fully works.
POIOverlay = function(marker, poi, type) { this._marker = marker; this._poi = poi; this._type = type; this._div = null; this.latlng_ = marker.getPosition(); this._map = marker.getMap(); this._offsetVertical = -195; this._offsetHorizontal = 0; this._height = 165; this._width = 266; } POIOverlay.prototype = new google.maps.OverlayView(); POIOverlay.prototype.create = function() { console.log(this) } POIOverlay.prototype.draw = function() {
However, making this a prototype, you cannot add any of the methods of the parent class:
POIOverlay = Class.create(new google.maps.OverlayView(), { initialize : function(marker, poi, type) { this._marker = marker; this._poi = poi; this._type = type; this._div = null; this.latlng_ = marker.getPosition(); this._map = marker.getMap(); this._offsetVertical = -195; this._offsetHorizontal = 0; this._height = 165; this._width = 266; }, create : function() { if(this._div) return; console.log(this); }, draw : function() {
Here is the code to create / use the class:
try { poio = new POIOverlay(marker,poi,type); } catch(e) { console.log(e); } google.maps.event.addListener(marker, 'click', poio.draw.bind(poio) );
In the first example, the console registers an object with parent and child methods / attributes. In the second example, the console registers an object without parent attributes / methods.
Obviously, this is not a big deal, but I was wondering if anyone else had this problem, and if it is easy to fix. I am using prototype 1.7.