Favourite Photos
electronicholas.com

Photos, Thoughts and Software from a worldly Entrepreneur

Subclassing Google Maps API (GMap2)

29 Feb 2008 - Javascript
I have been using my own subclassed version of the Google Maps GMap2 class for some time now. Here is how I do it:
function extend(subclass, superclass) { function Dummy() {} Dummy.prototype = superclass.prototype; subclass.prototype = new Dummy(); subclass.prototype.constructor = subclass; subclass.superclass = superclass; subclass.superproto = superclass.prototype; } function MyMapClass(DomElement) { MyMapClass.superclass.call(this, DomElement); this.enableScrollWheelZoom(); this.enableContinuousZoom(); this.mycustomattribute = []; }
Then:
extend(MyMapClass, GMap2); MMC = new MyMapClass(document.getElementById("map"));
Click here to leave a comment.

GMap MarkerManager

21 Jul 2007 - Javascript

It seems the GMarkerManager Class in the current version of the Google Maps API doesn't do useful things like allow you to remove markers from a manager instance or clear them all. Luckily, it looks like such functionality is being incorporated into a future version, as described here

At date of writing, the extra functions described in the link above are not available through the main GMap2 class, but instead must come from an instance of MarkerManager as shown in the example's source code. Include this javascript in your code and create an instance of MarkerManager:

mgr = new MarkerManager(map, {trackMarkers:true}); mgr.removeMarker(allmarkers[markerNum]); mgr.clearMarkers();

Click here to leave a comment.