angularjs-google-maps icon indicating copy to clipboard operation
angularjs-google-maps copied to clipboard

Custom markers disappear on second load

Open Vatsov opened this issue 10 years ago • 5 comments

Minimal demo

Current behavior

  • Load the map with custom markers
  • Press back button
  • Load the previous map
  • Мarkers are loaded just for the few milliseconds and after that disappear. (They are in html but with display none);

Expected/desired behavior

  • Markers should not disappear

Other information

  • On initial map load custom markers are loaded and everything works fine
  • With regular markers everything works
  • If repeat manually one by one the custom markers in order to exclude ng-repeat everything works.

Vatsov avatar Aug 25 '16 19:08 Vatsov

It's strange for me. as soon as I zoom in or out, marker shows up again. I need some more research on this.

Meanwhile, why don't you try removing element approach again?

allenhwkim avatar Aug 27 '16 17:08 allenhwkim

Adding zoom-to-include-markers="auto" to the ng-map element causes some markers to be displayed (4 on my browser) but not all of them: Codepen

alitto avatar Aug 27 '16 17:08 alitto

Yes, on my browser also are displaying only 4 of 5 markers after first time. The fifth marker also is visible but with very strange position: left: 4139px; top: -43040px;

The interesting part is that this approach works for map with clusterer. Codepen But unfortunately only if marker is in clusterer.

Vatsov avatar Aug 27 '16 19:08 Vatsov

I think i found the underlaying issue in the custom-marker directive. There was a 300ms delay between the calculation of the final position for the overlay's div and the update of its top/left coordinates which caused those strange positions for the markers. It looks like the first time the map was rendered this delay wasn't causing any problems, perhaps due to Google Maps initialization time being greater than that. I created PR #674 to fix this scenario.

alitto avatar Aug 28 '16 15:08 alitto

Thanks a lot

Vatsov avatar Aug 29 '16 08:08 Vatsov