1

Current Situation

I've implemented a Google Autocomplete text box into a web page, so that users can select a Google Place, and store that place/address information against their account. Basically crossing Google's Place Autocomplete demo with their Place Autocomplete Address demo

From the autocomplete "search" box, the user searches for an place (in this case, an establishment type). They then get a list of some closest-match options - and can select the right one from the list.

When they "select" a place, this raises a place_changed event.

From this event, I've been able to hook up a listener, which shows a map marker at the selected place and pops up an InfoWindow.

I've changed the "default" InfoWindow to my own, which allows the user to click a "Use" button if they so wish - which some JavaScript then takes care of and stores necessary data in some fields. Essentially, everything is done as per Google's documentation.

Everything's working hunky-dory, as I would like (yippee!).

Here's a sample:

Autocomplete with place selected


Consider this...

Now, let's say that the user has selected a "match" from the autocomplete dropdown. A map marker is added and the map is then focused to it, and the InfoWindow with "Use" button pops up (as above).

However, they decide not to "Use" it - they've seen another nearby place they wish to use.

From the map, the user can click on said alternative place, and another InfoWindow pops up, displaying the address and a link to "View on Google Maps".

Something like this:

Autocomplete alternative place selected

Note: I've noticed the content of the InfoWindow can sometimes vary on the special types of establishment - such as railway stations (the address isn't shown - just some symbols to signify it being a railway station). I'm not too fussed about this, as hopefully the answer to my question will render this void.


The Issue

It's obvious to see that clicking on a different location just brings up this "alternative" InfoWindow - I presume an event is fired and Google' JS handles it by launching another InfoWindow at the selected place.

I think it would be a much better user experience if the user were able to "Use" this other location they've clicked on, if they so desire. They currently would have to "search again" for that other location, essentially to end up at the same result as the first image.

Nowhere on the face of the Internet, am I able to find a way of manipulating clicking on an alternate place.

I've tried searching for an event to listen to, and then handle (in the same way I'm showing my custom InfoWindow from place_changed, through my own callback function).


What can I do?

I need to know the following:

  • What event is fired when an "alternative" location is selected from the map?
  • Does this event contain a place object, like in the place_changed event args?
  • If so, could I hookup to this event, passing said place into my existing JavaScript function which sets the map marker and opens the InfoWindow?

Thanks in advance for your help and suggestions - it's gratefully received, as always.

Geoff James
  • 3,122
  • 1
  • 17
  • 36
  • Probably this [question](http://stackoverflow.com/questions/21486868/click-event-listener-on-styled-map-icons-and-labels/21488643#21488643) can help. – xomena Jul 28 '16 at 14:22

0 Answers0