-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Normal
-
Affects Version/s: None
-
None
Steps to Reproduce
https://zkfiddle.org/sample/1b5jnh4/3-Gmaps-Markers-are-not-beeing-removed-after-change-lat-lng
Run fiddle (add gmap API key)
Zoom on the marker as far as possible (zoom will be logged > 19)
click button to move the map marker
Current Result
map marker is not moved, when map is zoomed < 19 again, another copy of the marker is created at the new location, but old marker is not cleared
Expected Result
map markers continue to work even if zoom > 19
Debug Information
Caused by the _findMaxZoomLevel function returning a max zoom level of 19 even though the map's actual max zoom level is 22 in this location
As a result, during _realBind, ZK initializes the map first, then initializes the MarkerManager instance for this component.
The marker manager gets initialized with a max zoom value of 19, so internally the marker manager doesn't generate layers for zoom levels > 19
If the marker is moved while the zoom level > 19, the marker manager just ignores the deletion request, and will not reattempt to delete the marker later once the zoom level goes back <19
Workaround
override the default value of _findMaxZoomLevel to 22 (current highest observed zoom level)
<script><![CDATA[ zk.afterLoad("gmaps", function () { var _xGmaps = {}; zk.override(gmaps.Gmaps.prototype, _xGmaps, { _findMaxZoomLevel: function() { var types = this._gmaps.mapTypes; var mapsMaxZoom = 22; for (var type in types ) { if (typeof types.get(type) === 'object' && typeof types.get(type).maxZoom === 'number') { var zoom = types.get(type).maxZoom; if (zoom > mapsMaxZoom) { mapsMaxZoom = zoom; } } } return mapsMaxZoom; } }); }); ]]></script>