It's clear that lots of people are running into this problem...
I have different sets of markers that need to change depending both on the zoom level (hierarchical clustering) and on a "category" (that I define). For a given category, I can add all the markers to a marker manager, and that works great. When I change zoom, things work fine.
Changing categories is the problem: When the category changes, I remove all overlays from the map (I know that doesn't remove the markers hidden by the marker manager), and create a new marker manager for the category. This also works fine, BUT if I then change the zoom level on the map, the old marker manager kicks in and shows markers from the old category at the new zoom level.
The GMarkerManager is useful, but I'm absolutely astounded that you can add markers to it but not remove markers. Or even just blow away a marker manager along with its markers. A data structure that you can create and add things to but not remove anything or ever delete?!
So, two questions:
(1) Can we have any assurance from the API team besides "we've read your post" that this will be fixed in the near future?
(2) Is there any workaround that does not involve memory leaks and old marker managers wasting CPU cycles?
Regarding (2), I ended with a hack found in the group which moves markers out of view (beyond the North Pole, actually) and back again as needed. This doesn't however prevent the GMarkerManager from checking the viewport for "hidden" markers, of course. I use the following functions:
function hideMarkers() { for (var id in allMarkers) try { allMarkers[id].savedPoint = allMarkers[id].getPoint(); allMarkers[id].setPoint(new GLatLng(91, 0)); } catch (e) { } markerMgr.refresh();
}
function showMarkers() { for (var id in allMarkers) try { allMarkers[id].setPoint(allMarkers[id].savedPoint); } catch (e) { } markerMgr.refresh();
}
In your case, I'd add all markers to a single GMarkerManager and make the functions hide/show markers depending on a category parameter.
Hi drm, Re 1), I've personally made the requested changes to the Marker Manager code. The changes are not yet released. Please stay tuned to the blog for announcements of the fixes. Sorry for the delay. I think you'll be pleased with the changes in the marker manager. -Pamela
On Mar 12, 9:54 am, "J." <jwornowit...@googlemail.com> wrote:
> Regarding (2), I ended with a hack found in the group which moves > markers out of view (beyond the North Pole, actually) and back again > as needed. This doesn't however prevent the GMarkerManager from > checking the viewport for "hidden" markers, of course. I use the > following functions:
> function hideMarkers() { > for (var id in allMarkers) > try { > allMarkers[id].savedPoint = allMarkers[id].getPoint(); > allMarkers[id].setPoint(new GLatLng(91, 0)); > } catch (e) { > } > markerMgr.refresh();
> }
> function showMarkers() { > for (var id in allMarkers) > try { > allMarkers[id].setPoint(allMarkers[id].savedPoint); > } catch (e) { > } > markerMgr.refresh();
> }
> In your case, I'd add all markers to a single GMarkerManager and make > the functions hide/show markers depending on a category parameter.
> Hi drm, > Re 1), I've personally made the requested changes to the Marker > Manager code. > The changes are not yet released. Please stay tuned to the blog for > announcements of the fixes. > Sorry for the delay. I think you'll be pleased with the changes in the > marker manager. > -Pamela
> On Mar 12, 9:54 am, "J." <jwornowit...@googlemail.com> wrote:
> > Hi drm,
> > Regarding (2), I ended with a hack found in the group which moves > > markers out of view (beyond the North Pole, actually) and back again > > as needed. This doesn't however prevent the GMarkerManager from > > checking the viewport for "hidden" markers, of course. I use the > > following functions:
> > function hideMarkers() { > > for (var id in allMarkers) > > try { > > allMarkers[id].savedPoint = allMarkers[id].getPoint(); > > allMarkers[id].setPoint(new GLatLng(91, 0)); > > } catch (e) { > > } > > markerMgr.refresh();
> > }
> > function showMarkers() { > > for (var id in allMarkers) > > try { > > allMarkers[id].setPoint(allMarkers[id].savedPoint); > > } catch (e) { > > } > > markerMgr.refresh();
> > }
> > In your case, I'd add all markers to a single GMarkerManager and make > > the functions hide/show markers depending on a category parameter.
> Do you have any idea when the changes will be release?
> Thanks!
> On Mar 12, 5:04 pm, "pamela" <pammyla....@gmail.com> wrote:
> > Hi drm, > > Re 1), I've personally made the requested changes to theMarker> Managercode. > > The changes are not yet released. Please stay tuned to the blog for > > announcements of the fixes. > > Sorry for the delay. I think you'll be pleased with the changes in the > >marker manager. > > -Pamela
> > On Mar 12, 9:54 am, "J." <jwornowit...@googlemail.com> wrote:
> > > Hi drm,
> > > Regarding (2), I ended with a hack found in the group which moves > > >markersout of view (beyond the North Pole, actually) and back again > > > as needed. This doesn't however prevent the GMarkerManager from > > > checking the viewport for "hidden"markers, of course. I use the > > > following functions:
Yes, it has been released as an open source project. What that blog post doesn't mention is that I added the delete and clear markers functionality requested. Please try it out and let me know if you encounter any issues. (If you'd like to work on it yourself, consider joining the project :) Thanks!
On Mar 27, 9:11 am, "kedoin" <ked...@gmail.com> wrote:
> On Mar 20, 7:46 pm, "dkraai" <k...@advpubtech.com> wrote:
> > Do you have any idea when the changes will be release?
> > Thanks!
> > On Mar 12, 5:04 pm, "pamela" <pammyla....@gmail.com> wrote:
> > > Hi drm, > > > Re 1), I've personally made the requested changes to theMarker> Managercode. > > > The changes are not yet released. Please stay tuned to the blog for > > > announcements of the fixes. > > > Sorry for the delay. I think you'll be pleased with the changes in the > > >marker manager. > > > -Pamela
> > > On Mar 12, 9:54 am, "J." <jwornowit...@googlemail.com> wrote:
> > > > Hi drm,
> > > > Regarding (2), I ended with a hack found in the group which moves > > > >markersout of view (beyond the North Pole, actually) and back again > > > > as needed. This doesn't however prevent the GMarkerManager from > > > > checking the viewport for "hidden"markers, of course. I use the > > > > following functions:
Thanks, this is terrific. Out of curiosity, is the GMarkerManager delete functionality going to be part of the main api or is it just provided as an example on the new open source site?
<api.pamela...@google.com> wrote: > Yes, it has been released as an open source project. > What that blog post doesn't mention is that I added the delete and > clear markers functionality requested.