Skip to content
Advertisement

Google Autocomplete API – format output result

I’m trying to implement Google Places API, so here is my code:

JavaScript

Google Autocomplete works fine, however I have one of requirements – only show street name & number instead of full address suggested by Google. So I can get all information by running autocomplete.getPlace() at “place_changed” event – there are no problems with that.

The problem is that I can’t override autocomplete input value with my custom text – I’ve tried to do it within “blur”, “focus”, “place_changed” events – still no luck. Please find an example of what I was trying. Also – I need to avoid text flashing, to make it absolutely user-friendly. Could someone help me with my attempts?

JSFiddle: http://jsfiddle.net/8pGH2/

Advertisement

Answer

I was able to solve my problem with the following code:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement