Skip to content

Commit

Permalink
Fix Marker rendering in strict mode (#471)
Browse files Browse the repository at this point in the history
  • Loading branch information
kolebjak authored Sep 27, 2022
1 parent dd206de commit d40abe2
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/Marker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,22 @@ const Marker = (props: MarkerProps) => {
sMarker.decorate(window.SMap.Marker.Feature.Card, card);
};

const {lng, lat} = props.coords;
const { lng, lat } = props.coords;
const coords = window.SMap.Coords.fromWGS84(lng, lat);
const options = resolveOptions();
const sMarker = new window.SMap.Marker(coords, props.id, options);
markerLayer?.addMarker(sMarker);

if (props.card) {
renderCard();
}

useEffect(() => {
markerLayer?.addMarker(sMarker);

if (props.card) {
renderCard();
}

return () => {
markerLayer.removeMarker(sMarker, true);
};
});
}, []);

return null;
};
Expand Down

0 comments on commit d40abe2

Please sign in to comment.