0

I'm interested in looking up establishments close to points on a map that a user selects by clicking. I added a click handler to the map using google.maps.event.addListener, which picks up the lat/lng of the clicked location. Works great.

The problem is that the map has POIs that when clicked, don't fire the normal event and display their own infowindow, so I have no idea where the user clicked. I can write some terrible code to inject content into the info window, but I'm not sure how to figure out the lat/lng of the POI.

In order of best solution to worst, I'd like to do one of the following:
1. Register for some kind of event to be notified when user click on POI, set my own content for the info window, and be notified of the lat/lng of POI.
2. Disable this infowindow for POIs, have the normal click handler fire.
3. Have the normal click handler fire when POI is clicked, as seen on https://developers.google.com/maps/documentation/javascript/events
4. Disable the POIs from showing up.

Any advice?

  • The only option of your list that works is to disable the POIs. Related question: [disable clickable landmark on google map](http://stackoverflow.com/questions/7267789/disable-clickable-landmark-on-google-map) – geocodezip Mar 23 '15 at 21:25
  • Note that the demo at https://developers.google.com/maps/documentation/javascript/events fires the click event when clicking on a POI, but I don't seem to have that happening in my app. What are they doing differently? – David Zbarsky Mar 23 '15 at 21:32
  • That seems to only happen in their documentation. [Fiddle containing the same code](http://jsfiddle.net/gg8zw5t4/), click event doesn't fire there. – geocodezip Mar 23 '15 at 21:41
  • Hmm, you're right =(. Maybe someone from Google Maps will see this and comment. – David Zbarsky Mar 23 '15 at 21:43

1 Answers1

0

I believe that it has something to do with the API version.

In the Fiddle @geocodezip mentioned, they load this API: https://maps.googleapis.com/maps/api/js?sensor=false&libraries=geometry,places&ext=.js

However, if you look at the documentation example, they load these 2 scripts: https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true
and
https://maps.gstatic.com/maps-api-v3/api/js/20/4/main.js

And it seems like if I load the same scripts in the Fiddle, click on POI works. I fork the demo here.

hope this help.

kaho
  • 4,746
  • 1
  • 16
  • 24