Josh-ES / react-here-maps

React.js HERE Maps component
MIT License
35 stars 25 forks source link

Marker does not clear previous position on map #29

Closed sanmit-vartak closed 2 years ago

sanmit-vartak commented 2 years ago

Whenever I change co-ordinates of the marker on map, new marker gets added with new co-ordinates along with old co-ordinate marker

Because of this I'm unable to change points of marker on map, I get multiple markers on each of points I have given to a single marker

here's sample code I'm using to hide and display my marker for confirming if marker can be hidden using jsx conditional rendering...

const toggleMarkers = () => {
    setShowMarkers((showMarkers) => !showMarkers);
};

<HPlatform
  apikey={process.env.HERE_MAPS_API_KEY}
  useCIT
  useHTTPS
  includeUI
  interactive
  includePlaces={false}
>
  <HMap>
    {(() => {
    if (showMarkers) return <HMapMarker coords={point} icon={destinationIcon} setViewBounds={false} />;
            return <div />;
    })()}
    </HMap>
</HPlatform>