This question is related to my question here:
Google Maps V3 -> Is it possible to get properties from Geojson using lat lng coordinates or other information from search box?
Since it is possible to trigger a click event programmatically like this, I'm wondering if I can trigger a click event on a given lat/lng position in the same way?
Example code:
google.maps.event.trigger(marker, 'click');
Pseudo code of what I would like to do:
google.maps.event.trigger(place.geometry.location, 'click');
How to trigger the onclick event of a marker on a Google Maps V3?
Given the documentation it is really a long shot, but it would solve my current problem.
.exp/reference#event
This question is related to my question here:
Google Maps V3 -> Is it possible to get properties from Geojson using lat lng coordinates or other information from search box?
Since it is possible to trigger a click event programmatically like this, I'm wondering if I can trigger a click event on a given lat/lng position in the same way?
Example code:
google.maps.event.trigger(marker, 'click');
Pseudo code of what I would like to do:
google.maps.event.trigger(place.geometry.location, 'click');
How to trigger the onclick event of a marker on a Google Maps V3?
Given the documentation it is really a long shot, but it would solve my current problem.
https://developers.google./maps/documentation/javascript/3.exp/reference#event
Share Improve this question edited Dec 27, 2017 at 10:07 beaver 17.7k2 gold badges43 silver badges68 bronze badges asked Dec 26, 2017 at 2:17 OgglasOgglas 70.6k42 gold badges380 silver badges474 bronze badges1 Answer
Reset to default 7You can try passing additional arguments to trigger
method:
var e = {
latLng: new google.maps.LatLng(-35, 151)
};
google.maps.event.trigger(map, 'click', e);
Here is a working example showing infoWindow every time map is clicked (or on programmatic trigger): https://jsfiddle/beaver71/5ndjq8ge/