question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

e.getMarkers() - how can i get markers with props?

See original GitHub issue

I have this code:

<MarkerClusterer
      averageCenter
      enableRetinaIcons
      gridSize={60}
      onClick={onClickCluster}
      zoomOnClick={false}
    >
      {[
        { x: 45, y: 40, id: 0 },
        { x: 46, y: 40, id: 1 },
        { x: 45, y: 41, id: 2 },
        { x: 45, y: 42, id: 3 },
        { x: 45.05, y: 40, id: 4 },
      ]
        .map((el, i) => (
          <Marker
            position={{ lat: el.x, lng: el.y }}
            onClick={e => onClickMarker(e, el)}
            id={i}
            ref={refMarkers}
          />
        ))}
    </MarkerClusterer>

If i use e.getMarkers- i get array of objects with markers but they don’t have props. How can i get array of markers with props? I want to know ids from props of marker which contents cluster (when user click on cluster).

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

11reactions
DonnyVerduijncommented, Dec 19, 2017

You should assign an id to a marker instance, by passing in an object to the options prop. These properties will be available through the marker instances when using getMarkers(). Note that while you can pass any key with any value you like, i would advise against doing this.

<MarkerClusterer> 
   <Marker options={{ id: 123, foo: "bar" }} />
</MarkerClusterer>

0reactions
ajay-bsoftcommented, Jan 15, 2020

@DonnyVerduijn Thanks a lot!. This options also work in MarkerWithLabel.

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-google-maps pass props on marker click - Stack Overflow
Pass props to parent component in React.js ... Usually you want to map the locations and each location should have some kind of...
Read more >
react-native-maps.MapView.Marker JavaScript and Node.js ...
How to use. Marker. function ... const Map = props => <MapView style={styles.map} width={props.width} ... render() { let marker = null; if (this.state....
Read more >
React Google Maps Api Style Guide
The simplest way to get a functional map is: ⚠️ Make sure you cache the props passed to GoogleMap to avoid re-renders that...
Read more >
photo-sphere-viewer - UNPKG
photo-sphere-viewer/dist/plugins/markers.js.map. Version: ... stopPropagation();\n }\n\n // the marker could have been deleted in an event handler\n if ...
Read more >
tomchentw/react-google-maps - Gitter
So to make it work with react, the script tag is dynamically added and asynced so react knows when it finishes loading it....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found