How to call the marker.click function from outside the map? #40
Comments
Hi, you can use |
Thanks for the quick response. I tried using the click event. I get the following error: I guess the way i extract the markers is wrong. Right now I do it like this, Is there a correct way of extracting the marker object? Thanks again for the quick reply. |
That's the right way, it shouldn't throw any error. I'm gonna check this bug. |
Hi, The issue was solved. Calling the marker's click event using the google.maps.event.trigger method solved the issue. var ourMarker = getMarker(title)
google.maps.event.trigger(ourMarker, 'click'); |
function addMarker(lat, lng, info ,color) } hello my issue is that , i would like to change the marker color on mouse over on listing , so how can i bind the our listing to marker ? |
How to click map location instead of marker |
This does not work in clustered markers (one of the group markers) situation. Please share suggestion if you have. Thanks. |
Hi @kamleshwebtech you'll probably need to attach your click events into the marker cluster, since the markers aren't in the map when they grouped. Check this example: https://googlemaps.github.io/v3-utility-library/packages/markerclustererplus/examples/events_example.html |
Hi @kamleshwebtech and @hpneo , I am still not able to trigger click event on clustered markers. Can you share example code if possible? |
@kavishatalsania Please check this demo |
@kamleshwebtech Thank you sharing this link. I want to open a info window of a marker which is inside map cluster. For other marker |
@kavishatalsania do you have a working example where I can debug? |
@hpneo This is the working example: https://codesandbox.io/s/new-bird-8fp0q?file=/src/index.ts On line 58, I triggered event for marker[0] which is not inside any marker cluster. That is why it it working as expected. Please change line number 58 to |
@kavishatalsania I'm sorry but that example doesn't event use GMaps. If you are using GMaps with MarkerClusterer I recommend you to create a new issue. |
Hi,
This is not an issue, just a query.
I am building a map with several markers (and infoWindows). Now when a marker is clicked, the corresponding infoWindow is displayed (with proper screen positioning). I want to do the same when a place is selected from a drop down list. How can I hook into the google.maps.Marker's click event?
I can call, "map.hideInfoWindows()" followed by "marker[i].infoWindow.open". This does show the info window. But the displayed widow is not centered. And also it does not have any of the events associated with it. I cannot close this window using the "close" button.
Could you please help me with this?
Siddharth
The text was updated successfully, but these errors were encountered: