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

How to animate a marker when clicking on an item?

Open maevanap opened this issue 8 years ago • 1 comments

Hi guys,

I got a particular case that I struggle with. I have a list (<li>) in the <LocationsList /> component which is created based on an array of locations (JSON file).

In the <GoogleMaps /> component I render the Map with a marker for each location.

I try to animate the corresponding marker when I click on the name of the location in the LocationList. I tried using setAnimation but I don't really know how to use it (it throws an error which says the function isn't defined).

Here is my last piece of code: In the GoogleMaps component

{locations.map(location =>
   <Marker
      key={location.key}
      title={location.title}
      name={location.name}
      position={location.position}
      onClick={this.onMarkerClick}
      animation={(currentMarker === location.title)
         && this.props.google.maps.Animation.BOUNCE}
   />
)}

the currentMarker lives in the <App /> state and is updated when I click on the item of the LocationsList.

Here is my repo if needed: https://github.com/maevanapcontact/fend-neighborhood-maps

Here is my StackOverflow post: https://stackoverflow.com/questions/51160344/animate-marker-when-click-on-a-list-item-google-maps-react

Thanks guys!

maevanap avatar Jul 03 '18 22:07 maevanap

Did you got any further with this?

ginuxone avatar Jan 07 '19 23:01 ginuxone