when zooming in or out of your maps after hiding them using MarkerManager the markers re-appear.
I used Mike William's hack
me.addOverlay_ = function(marker) { map.addOverlay(marker); if (marker.isHidden()){marker.show();marker.hide()} me.shownMarkers_++; };
And it worked about a month ago - now its not working. Is anyone else using this hack and has it stopped working?
I also see that this issue is listed as a bug, but its been there for a while - does google plan to fix this or should I dump the markermanager and just go with removeOverlay?
I believe there was a recent change in behavior where a marker that has been removed will have it's hidden-ness reset. It was more of a design decision than a bug. A marker.setVisible() function would make more sense in this situation. Anyway, I would suggest the following: 1) Whenever you call marker.hide(), say marker.pleaseHideLater = true 2) In the addOverlay_ function you quoted, have: if (marker.pleaseHideLater) { marker.hide() } 3) Whenever you call marker.show(), say marker.pleaseHideLater = false
I haven't tried that out, but I believe it should work (and not be as subject to API changes). Sorry for the hassle. - pamela
On Sep 14, 5:47 am, coreykliewer <coreyklie...@gmail.com> wrote:
> And it worked about a month ago - now its not working. Is anyone else > using this hack and has it stopped working?
> I also see that this issue is listed as a bug, but its been there for > a while - does google plan to fix this or should I dump the > markermanager and just go with removeOverlay?
I don't want to hijack this thread, but in tests I did with moderate numbers of markers (hundreds to several thousand) I found that .addMarkers(...) and .clearMarkers() were considerably more efficient that .show()/.hide() (yes with Mike's so-called hack). Developers might just want to consider this approach and do some testing for their own situation.
I create multiple instances of the MM so each class of my markers would have it's own MM. This way I could turn them on or off independently. Obviously with show()/hide() you can do something similar.
Regards Richard aka Papa Bear
On Sep 13, 4:54 pm, "pamela (Google Employee)" <pamela....@gmail.com> wrote:
> I believe there was a recent change in behavior where a marker that > has been removed will have it's hidden-ness reset. It was more of a > design decision than a bug. A marker.setVisible() function would make > more sense in this situation. > Anyway, I would suggest the following: > 1) Whenever you call marker.hide(), say marker.pleaseHideLater = true > 2) In the addOverlay_ function you quoted, have: > if (marker.pleaseHideLater) { marker.hide() } > 3) Whenever you call marker.show(), say marker.pleaseHideLater = false
> I haven't tried that out, but I believe it should work (and not be as > subject to API changes). Sorry for the hassle. > - pamela
> On Sep 14, 5:47 am, coreykliewer <coreyklie...@gmail.com> wrote:
> > when zooming in or out of your maps after hiding them using > > MarkerManager the markers re-appear.
> > And it worked about a month ago - now its not working. Is anyone else > > using this hack and has it stopped working?
> > I also see that this issue is listed as a bug, but its been there for > > a while - does google plan to fix this or should I dump the > > markermanager and just go with removeOverlay?
> I believe there was a recent change in behavior where a marker that > has been removed will have it's hidden-ness reset. It was more of a > design decision than a bug. A marker.setVisible() function would make > more sense in this situation. > Anyway, I would suggest the following: > 1) Whenever you call marker.hide(), say marker.pleaseHideLater = true > 2) In the addOverlay_ function you quoted, have: > if (marker.pleaseHideLater) { marker.hide() } > 3) Whenever you call marker.show(), say marker.pleaseHideLater = false
> I haven't tried that out, but I believe it should work (and not be as > subject to API changes). Sorry for the hassle. > - pamela
> On Sep 14, 5:47 am, coreykliewer <coreyklie...@gmail.com> wrote:
> > when zooming in or out of your maps after hiding them using > > MarkerManager the markers re-appear.
> > And it worked about a month ago - now its not working. Is anyone else > > using this hack and has it stopped working?
> > I also see that this issue is listed as a bug, but its been there for > > a while - does google plan to fix this or should I dump the > > markermanager and just go with removeOverlay?
> I don't want to hijack this thread, but in tests I did with moderate > numbers of markers (hundreds to several thousand) I found > that .addMarkers(...) and .clearMarkers() were considerably more > efficient that .show()/.hide() (yes with Mike's so-called hack). > Developers might just want to consider this approach and do some > testing for their own situation.
> I create multiple instances of the MM so each class of my markers > would have it's own MM. This way I could turn them on or off > independently. Obviously with show()/hide() you can do something > similar.
> > I believe there was a recent change in behavior where a marker that > > has been removed will have it's hidden-ness reset. It was more of a > > design decision than a bug. A marker.setVisible() function would make > > more sense in this situation. > > Anyway, I would suggest the following: > > 1) Whenever you call marker.hide(), say marker.pleaseHideLater = true > > 2) In the addOverlay_ function you quoted, have: > > if (marker.pleaseHideLater) { marker.hide() } > > 3) Whenever you call marker.show(), say marker.pleaseHideLater = false
> > I haven't tried that out, but I believe it should work (and not be as > > subject to API changes). Sorry for the hassle. > > - pamela
> > On Sep 14, 5:47 am, coreykliewer <coreyklie...@gmail.com> wrote:
> > > when zooming in or out of your maps after hiding them using > > > MarkerManager the markers re-appear.
> > > And it worked about a month ago - now its not working. Is anyone else > > > using this hack and has it stopped working?
> > > I also see that this issue is listed as a bug, but its been there for > > > a while - does google plan to fix this or should I dump the > > > markermanager and just go with removeOverlay?
> I believe there was a recent change in behavior where a marker that > has been removed will have it's hidden-ness reset. It was more of a > design decision than a bug. A marker.setVisible() function would make > more sense in this situation. > Anyway, I would suggest the following: > 1) Whenever you call marker.hide(), say marker.pleaseHideLater = true > 2) In the addOverlay_ function you quoted, have: > if (marker.pleaseHideLater) { marker.hide() } > 3) Whenever you call marker.show(), say marker.pleaseHideLater = false
> I haven't tried that out, but I believe it should work (and not be as > subject to API changes). Sorry for the hassle. > - pamela
> On Sep 14, 5:47 am, coreykliewer <coreyklie...@gmail.com> wrote:
> > when zooming in or out of your maps after hiding them using > > MarkerManager the markers re-appear.
> > And it worked about a month ago - now its not working. Is anyone else > > using this hack and has it stopped working?
> > I also see that this issue is listed as a bug, but its been there for > > a while - does google plan to fix this or should I dump the > > markermanager and just go with removeOverlay?
> I put a control button on the map to show or hide a class of markers > the button calls a toggle function The toggle will either turn them on or off. It has 4 arguments: 1) "hide" (boolean) - which tells it to hide or show the markers, 2) "MM" (object) - the instance of the Marker Manager for this class of markers, 3) "markers" - the array of markers generated when I created the markers the first time, and 4) "zoom" (number) - the zoom level for this class. Note that the "show" functionality is exactly the same as when the markers are added the first time.
Like this (slightly simplified for this note):
function toggleMarkers(hide, MM, markers, zoom) { if (hide) { MM.clearMarkers(); } else { MM.addMarkers(markers,zoom) MM.refresh() }
}
My actual code is a bit harder to understand since the Marker Manager names and the array names use the color of the marker as part of the name, so there's a bunch of eval() functions in there.
You should see a map of Brooklyn New York. There are an assortment of red, green and white markers on the map. There is a control button on the top left labelled "Toggle Markers, Labels On/Off". Put the mouse over that button and you will see a drop down list. Click on the list items to turn on or off markers of a particular color. As long as you keep the mouse over the list, you can click them on or off to your heart's content. As for performance, the red show all in that class (78). The green and White are cluster markers which represent over a hundred (actual 106 green and 170 white). The cluster markers plus the underlying markers are all in the Marker Manager at appropriate zoom levels. I have other maps with up to 3500 markers and the performance is not too bad.
> > I believe there was a recent change in behavior where a marker that > > has been removed will have it's hidden-ness reset. It was more of a > > design decision than a bug. A marker.setVisible() function would make > > more sense in this situation. > > Anyway, I would suggest the following: > > 1) Whenever you call marker.hide(), say marker.pleaseHideLater = true > > 2) In the addOverlay_ function you quoted, have: > > if (marker.pleaseHideLater) { marker.hide() } > > 3) Whenever you call marker.show(), say marker.pleaseHideLater = false
> > I haven't tried that out, but I believe it should work (and not be as > > subject to API changes). Sorry for the hassle. > > - pamela
> > On Sep 14, 5:47 am, coreykliewer <coreyklie...@gmail.com> wrote:
> > > when zooming in or out of your maps after hiding them using > > > MarkerManager the markers re-appear.
> > > And it worked about a month ago - now its not working. Is anyone else > > > using this hack and has it stopped working?
> > > I also see that this issue is listed as a bug, but its been there for > > > a while - does google plan to fix this or should I dump the > > > markermanager and just go with removeOverlay?
Ok, I hope I'm not confusing here - but I found a better way to manage the hide markers!
The problem with the the above solutions is that when you zoom out all the markers do a quick flash appearance and then they disappear when the addOverlay_ function is called - so what I did was this
I changed the addOverlay_ function to this:
me.addOverlay_ = function(marker) { if (!marker.pleaseHideLater) {map.addOverlay(marker);} me.shownMarkers_++; };
And where I call marker.show() I do a map.overlay(marker); so that line reads map.addOverlay(marker); marker.show(); marker.pleaseHideLater = false;
and whereever I call marker.hide() I also keep the marker.pleaseHideLater = true statement that Pamela stated above.
Now your map cleanly shows and hides your markers without any flashing markers when you zoom in and out
Hope this helps who ever is looking for this.
Corey
On Sep 13, 4:54 pm, "pamela (Google Employee)" <pamela....@gmail.com> wrote:
> I believe there was a recent change in behavior where a marker that > has been removed will have it's hidden-ness reset. It was more of a > design decision than a bug. A marker.setVisible() function would make > more sense in this situation. > Anyway, I would suggest the following: > 1) Whenever you call marker.hide(), say marker.pleaseHideLater = true > 2) In the addOverlay_ function you quoted, have: > if (marker.pleaseHideLater) { marker.hide() } > 3) Whenever you call marker.show(), say marker.pleaseHideLater = false
> I haven't tried that out, but I believe it should work (and not be as > subject to API changes). Sorry for the hassle. > - pamela
> On Sep 14, 5:47 am, coreykliewer <coreyklie...@gmail.com> wrote:
> > when zooming in or out of your maps after hiding them using > > MarkerManager the markers re-appear.
> > And it worked about a month ago - now its not working. Is anyone else > > using this hack and has it stopped working?
> > I also see that this issue is listed as a bug, but its been there for > > a while - does google plan to fix this or should I dump the > > markermanager and just go with removeOverlay?
I'm not sure you're referring to my example or not, but if you are, you may be confusing the hide/show function with the marker manager functionality.
> when I hide a marker with my control button, it stays hidden regardless of
zoom level, it does not flash in and out of vivibility when you change zoom level.
> when you use the cluster markers in my example to zoom in, it does nothing
more than zoom in (or out, as the case may be). The logic of the marker manager is responsible for the flashing affect and that has nothing to do with the hide/show logic.
The hide/show scheme you are putting together seems sound. The suggestion of my scheme which uses addMarkers/clearMarkers is simply an alternative that may have performance advantages in certain situations.
Regards Richard aka Papa Bear
On 9/14/07, coreykliewer <coreyklie...@gmail.com> wrote:
> Ok, I hope I'm not confusing here - but I found a better way to manage > the hide markers!
> The problem with the the above solutions is that when you zoom out all > the markers do a quick flash appearance and then they disappear when > the addOverlay_ function is called - so what I did was this
> And where I call marker.show() I do a map.overlay(marker); so that > line reads > map.addOverlay(marker); > marker.show(); > marker.pleaseHideLater = false;
> and whereever I call marker.hide() I also keep the > marker.pleaseHideLater = true statement that Pamela stated above.
> Now your map cleanly shows and hides your markers without any flashing > markers when you zoom in and out
> Hope this helps who ever is looking for this.
> Corey
> On Sep 13, 4:54 pm, "pamela (Google Employee)" <pamela....@gmail.com> > wrote: > > Hi Corey,
> > I believe there was a recent change in behavior where a marker that > > has been removed will have it's hidden-ness reset. It was more of a > > design decision than a bug. A marker.setVisible() function would make > > more sense in this situation. > > Anyway, I would suggest the following: > > 1) Whenever you call marker.hide(), say marker.pleaseHideLater = true > > 2) In the addOverlay_ function you quoted, have: > > if (marker.pleaseHideLater) { marker.hide() } > > 3) Whenever you call marker.show(), say marker.pleaseHideLater = false
> > I haven't tried that out, but I believe it should work (and not be as > > subject to API changes). Sorry for the hassle. > > - pamela
> > On Sep 14, 5:47 am, coreykliewer <coreyklie...@gmail.com> wrote:
> > > when zooming in or out of your maps after hiding them using > > > MarkerManager the markers re-appear.
> > > And it worked about a month ago - now its not working. Is anyone else > > > using this hack and has it stopped working?
> > > I also see that this issue is listed as a bug, but its been there for > > > a while - does google plan to fix this or should I dump the > > > markermanager and just go with removeOverlay?