Giter Club home page Giter Club logo

Comments (4)

blake-simpson avatar blake-simpson commented on May 28, 2024

If you check the source code for that example you'll find that only the latitude and longitude values are meant to be updated on the "dragged" event. This is to demonstrate that a user may provide a correct address but the marker position may be slightly wrong initially, so they can drag to the correct position without invalidating the address.

from geocomplete.

 avatar commented on May 28, 2024

Is it possible to get updated address data in a simple way on this event?

from geocomplete.

simplenotezy avatar simplenotezy commented on May 28, 2024

+1 I would like this aswell

from geocomplete.

Gitesh502 avatar Gitesh502 commented on May 28, 2024

$("#geocomplete").bind("geocode:dragged", function (event, latLng)
{

            var latlng = new google.maps.LatLng(latLng.lat(), latLng.lng());
            var geocoder = geocoder = new google.maps.Geocoder();
            geocoder.geocode({ 'latLng': latlng }, function (results, status)
            {
                if (status == google.maps.GeocoderStatus.OK)
                {



                    if (results[0])
                    {

                        $("#geocomplete").val(results[0].formatted_address)
                        console.log(results[0])
                        $.each(results[0].address_components, function (index, data)
                        {
                            if (data.types[0] == "country")
                            {
                                $("#country").val(data.long_name)
                                console.log("Country =" + data.long_name)
                            }
                            if (data.types[0] == "administrative_area_level_1")
                            {
                                $("#administrative_area_level_1").val(data.long_name)
                                console.log("State =" + data.long_name)
                            }
                            if (data.types[0] == "administrative_area_level_2")
                            {
                                $("#administrative_area_level_2").val(data.long_name)
                                console.log("District=" + data.long_name)
                            }
                            if (data.types[0] == "administrative_area_level_3")
                            {
                                $("#administrative_area_level_3").val(data.long_name)
                                console.log("City=" + data.long_name)
                            }
                            if (data.types[0] == "country")
                            {
                                console.log("Country=" + data.long_name)
                            }
                            if (data.types[0] == "postal_code")
                            {
                                $("#postal_code").val(data.long_name)
                                console.log("postal_code=" + data.long_name)
                            }
                            //alert("Location: " + results[1].formatted_address);
                        });
                    }
                }
            });

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.