My end users are not sophisticated web users and they might not get the
concept of the Autocomplete selection concept. Barring any usability issues
I am happy to contend with, I want to be able to trigger the place_changed
event so that I can get the geo-code address information from the "FIRST"
address shown in the autocomplete pop-up. This way the users can ignore the
autocomplete pop-up and the feature can be "SMART" about the search
criteria and default to the 1st item shown in the pop-up.
// autocomplete call back
function callBack() {
var place = this.getPlace();
}
function auto() {
input = document.getElementById('inputSearch');
autocomplete = new google.maps.places.Autocomplete(input);
google.maps.event.addDomListener(autocomplete, 'place_changed', callBack);
}
$(document).ready(function() {
// this should trigger after user hits the tab key in the input
field after entering some matched text
$(input).focusout(function(){
// get the first item of the autocomplete pop-up
var searchAddress = $(from).find('.pac-item:first').text();
// update the search field with the new value
$(input).val(searchAddress);
// trying to execute the same event as that's triggered when
the user SELECTS an item from the Autocomplete pop-up
$(from).find('.pac-item:first').trigger('click');
});
});
The problem is when I issue the click trigger, it doesn't invoke indirectly
the place_changed event. this->getPlace is always 'undefined' in the
autcomplete callback handler.
Any ideas?
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-maps-js-api-v3/-/PZt8O9LxgE8J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.