Skip to content

Commit b794af3

Browse files
fixes: error thrown on zooming and loading more stops
1 parent 3c0f14f commit b794af3

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/components/map/MapView.svelte

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,8 @@
8787
}
8888
8989
function clearAllMarkers() {
90-
markers.forEach(({ marker, overlay, element }) => {
91-
mapInstance.removeMarker(marker);
92-
93-
if (overlay) {
94-
overlay.setMap(null);
95-
overlay.draw = () => {};
96-
overlay.onRemove?.();
97-
}
98-
element?.parentNode?.removeChild(element);
90+
markers.forEach((markerObj) => {
91+
mapInstance.removeMarker(markerObj);
9992
});
10093
markers = [];
10194
}

src/lib/Provider/GoogleMapProvider.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,20 @@ export default class GoogleMapProvider {
6666
});
6767

6868
const overlay = new google.maps.OverlayView();
69-
overlay.setMap(this.map);
70-
overlay.draw = function () {
69+
overlay.onAdd = function() {
70+
this.getPanes().overlayMouseTarget.appendChild(container);
71+
};
72+
overlay.draw = function() {
7173
const projection = this.getProjection();
7274
const position = projection.fromLatLngToDivPixel(marker.getPosition());
7375
container.style.left = position.x - 20 + 'px';
7476
container.style.top = position.y - 20 + 'px';
7577
container.style.position = 'absolute';
76-
this.getPanes().overlayMouseTarget.appendChild(container);
7778
};
79+
overlay.onRemove = function() {
80+
container.parentNode.removeChild(container);
81+
};
82+
overlay.setMap(this.map);
7883

7984
return { marker, overlay, element: container };
8085
} catch (error) {

0 commit comments

Comments
 (0)