Google Maps is great, but some hacks are needed
I’m currently working on an AJAX-driven site also using Google Maps’ externally accessible API. But I have as several others been frustrated about the fact, that the GMarkerManager-class does not contain a clearMarkers method. So I combined the open-sourced source with the latest closed-source release, and mashed stuff up like this:
- // hack GMarkerManager to contain a method for clearing all markers
- GMarkerManager.prototype.clearMarkers = function() {
- var me = this;
- //
- // clear currently shown
- if (me.Wd > 0) {
- me.Id(me.K, me.Kd);
- }
- //
- // reset arrays
- var maxZoom = me.df;
- var maxWidth = 256;
- for (var zoom = 0; zoom < maxZoom; ++zoom){
- me.ed[zoom] = [];
- me.oc[zoom] = 0;
- me.gc[zoom] = Math.ceil(maxWidth/me.Ec);
- maxWidth <<= 1;
- }
- me.refresh();
- }
It is “hardcoded” to version 2.76 and will need to be changed for later versions of the API, but for now it must do
Feel free to use under the given license.
























