Giter Club home page Giter Club logo

Comments (8)

aemkei avatar aemkei commented on May 28, 2024

That should be no problem!

EG:

$("#geocomplete").geocomplete("find", "Juliusstraße 25, Hamburg");

from geocomplete.

martinb07 avatar martinb07 commented on May 28, 2024

That's not what I mean.
For example, I search for the O2 Arena in Berlin and I want to populate the address field with street and number.

from geocomplete.

aemkei avatar aemkei commented on May 28, 2024

If Google has information about that place, it will return street number.

Try http://ubilabs.github.com/geocomplete/examples/form.html with "Fernsehturm Berlin".

from geocomplete.

martinb07 avatar martinb07 commented on May 28, 2024

And how can I combine the route and street_number in one input field as a value?

from geocomplete.

aemkei avatar aemkei commented on May 28, 2024

This is not possible for now.

Feel free to tweak the code around Line 196:
https://github.com/ubilabs/geocomplete/blob/master/jquery.geocomplete.js#L196

from geocomplete.

 avatar commented on May 28, 2024

It may be late.... but use the events

$("#geocomplete")
    .geocomplete()
    .bind("geocode:result", function(event, result){
        var stno = result.address_components[0]['long_name'];
        var stna = result.address_components[1]['long_name'];
        $('#street').val(stno + ' ' + stna);
    });

from geocomplete.

 avatar commented on May 28, 2024

or even

$('#street').val(result.name);

from geocomplete.

 avatar commented on May 28, 2024

Change that.... if the field is pre-populated - you will not get "result.name"

and "result.address_components[0]" could be street number but it could be subpremise which means you need to check types array too.

try this way instead

        $("#geocomplete")
            .geocomplete()
            .bind("geocode:result", function(event, result){
                var addressArray = result.address_components;
                var street = "";
                for (var j = 0; j < addressArray.length; j++){
                    var typeName = addressArray[j].types[0];
                    if (typeName == 'subpremise') {
                        street += addressArray[j].long_name + '/';
                    }
                    if (typeName == 'street_number') {
                        street += addressArray[j].long_name + ' ';
                    }
                    if (typeName == 'route') {
                        street += addressArray[j].long_name;
                    }
                }
                $('#street').val(street);
            });

from geocomplete.

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.