#Geo - Prefill Address or Street using Google API

Comments

9 comments

  • Avatar
    Tony Ruth

    This is great Matthew, thanks for sharing! It would be interesting to hear all the different use cases around this.

    0
    Comment actions Permalink
  • Avatar
    jzhang

    thanks

    0
    Comment actions Permalink
  • Avatar
    Brett

    Thanks Matthew, I'm new to the iform format. How do you link the Java script at the form level to the element. ie. can you please explain "getStreetName(location1.latitude, location1.longitude)") in the dynamic value of the element you want prefilled. What input to you attache the dynamic value to?

    0
    Comment actions Permalink
  • Avatar
    Hamish

    Thanks Matthew - this is excellent. I've been trying to get it going for Android as well as iOS (which is working well) - I'd thought it was because Android didn't provide .latitude and .longitude - but that's wrong so it seems to be around XMLHttpRequest not work - any one with any ideas??

    1
    Comment actions Permalink
  • Avatar
    Matthew Huska

    It appears this is a known issue with Android. See the following article... http://www.kinvey.com/blog/107/how-to-build-a-service-that-supports-every-android-browser.

    We work exclusively with iOS devices so I have no proven solution.

    1
    Comment actions Permalink
  • Avatar
    Hamish

    Hi Matthew - thanks for response. In testing the code on Android the function call fails at this point " xmlHttp = new XMLHttpRequest();" it never gets past this point - IE before it sends the request. So not sure if it is the issue you point to. We have about 40-50% Android users so will keep trying to figure out where it fails.

    1
    Comment actions Permalink
  • Avatar
    Jonathan Hsu

    I found the functions would break the field if that specific data point (normally it was the zip code) was not applicable.  I fixed up the functions a bit and also added a getFormattedAddress() function.

    https://gist.github.com/jhsuZerion/4f9a9bb44f7021f792a71b6ca6ac934a 

    0
    Comment actions Permalink
  • Avatar
    Brant

    I'm having some trouble getting this to function properly.  I pasted the code into the page level javascript of my form, inserted my Google API key, and tried calling on the functions in various form elements, but nothing seems to populate in the form.  Could I be missing something?

    0
    Comment actions Permalink
  • Avatar
    Penny Lau

    I know this is a very late reply and we apologize, but for those folks who were struggling with making API calls work on Android, unfortunately Android JS library doesn't support XmlHttpRequest. Android JS is handled by Android webkit and you will be able to find all the classes supported: https://developer.android.com/reference/android/webkit/package-summary.html

    Penny

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk