Git Product home page Git Product logo

Comments (4)

sgruhier avatar sgruhier commented on July 16, 2024

Hi
Not sure if address_components[0].long_name is reliable

If you change line 114 from

results[i].label = results[i].formatted_address;

to
results[i].label = results[i].address_components[0].long_name;

doe it work?

On Dec 13, 2011, at 3:48 PM, ajacquot wrote:

First off thank for this piece of code, it works great!

Here is what I am trying to do: when you pick a location in the auto-complete drop down menu, it fill the input field with selected value, for example, if I am trying to find the Empire State Building in new York, the selected value will end up being: "Empire State Bldg, New York, NY 10001, USA".

I would like instead to have "Empire State Bldg" :i.e. address_components[0].long_name

In your example, I tried to add something like this in _focusAddress:
this.addresspicker_map.val(address.address_components[0].long_name);

This works fine to extract address_components[0].long_name to another #id, but does not work to extract it to the main input field.

If this is confusing, here is a site where what I am trying to achieve has been implemented:
http://traveltriangle.com/#search_trips

Any advice will be appreciated.

Thanks.


Reply to this email directly or view it on GitHub:
#6

from jquery-addresspicker.

ajacquot avatar ajacquot commented on July 16, 2024

Hey, thanks for taking a look!

That does not work, because it populates the drop down with address_components[0].long_name... so "Paris, TX" and "Paris, France" are both listed as "Paris" in the drop down...

I would like the drop down to be populated with formatted_address (as you have by default), but once one of the drop down options is selected, the associated text input field is populated with address_components[0].long_name (in the example above, just "Paris")

from jquery-addresspicker.

sgruhier avatar sgruhier commented on July 16, 2024

Ah ok I didn't understand. It's pretty easy as jQuery UI can do that
after line 114

  results[i].label =  results[i].formatted_address;

just add

  results[i].value = results[i].address_components[0].long_name;

jQuery UI will use label for AC text, and value for selected text
May be add a condition to test if results[i].address_components[0] exists

from jquery-addresspicker.

ajacquot avatar ajacquot commented on July 16, 2024

Wow! Perfect! Thanks a lot.

from jquery-addresspicker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.