Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8815815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:28:14+00:00 2026-06-14T04:28:14+00:00

This is the code I am working from: http://jsfiddle.net/njDvn/75/ var GeoCoded = {done: false};

  • 0

This is the code I am working from:

http://jsfiddle.net/njDvn/75/

var GeoCoded = {done: false};

$(document).ready(function(){
    console.log('ready!');
    autosuggest();
    console.log($('#myform input[type="submit"]'));
    $('#myform').on('submit',function(e){


        if(GeoCoded.done)
            return true;

        e.preventDefault();
        console.log('submit stopped');
        var geocoder = new google.maps.Geocoder();
        var address = document.getElementById('location').value;

        $('#myform input[type="submit"]').attr('disabled',true);

        geocoder.geocode({
            'address': address
        }, 
        function (results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                var latLng = results[0].geometry.location;
                $('#lat').val(results[0].geometry.location.lat());
                $('#lng').val(results[0].geometry.location.lng());
                //if you only want to submit in the event of successful geocoding, you can only trigger submission here.
                GeoCoded.done = true;
                $('#myform').submit();
            } else {
                console.log("Geocode was not successful for the following reason: " + status);
                //enable the submit button
                $('#myform input[type="submit"]').attr('disabled',false);
            }


        });        

    });    

});

This works how I want BUT, I wanted to complete the geocode when someone clicks on the autocomplete. So, when they type something and click on a suggestion from the autosuggest list, it actually completes the geocode call when the click the result.

If anyone could tell me if this is possible I would really appreciate it, because I havent been able to figure out how to do it myself.
​

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:28:15+00:00Added an answer on June 14, 2026 at 4:28 am

    Autocomplete incorporates geocoding automatically. Example here.

    Edit:

    Here is the gist of that example:

    The key lines for creating the autocomplete control are:

    var input = document.getElementById('searchTextField');
    var options = {
        types: [],
        componentRestrictions: {country: 'us'}
    };
    
    var autocomplete = new google.maps.places.Autocomplete(input, options);
    

    You also need to load the Places library:

    <script src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
    

    and in your HTML:

    <input id="searchTextField" type="text" size="50" value="">
    

    By the way, you don’t “add autocomplete to the geocoder”.The Places Autocomplete class includes geocoding capabilities.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the code I'm working from: http://jsfiddle.net/njDvn/36/ The weird thing is, the autosuggest
This is the code im working from: http://jsfiddle.net/X9SkK/ This is the javascript: function showmap()
This is the code im working from: http://jsfiddle.net/GCt3z/32/ It was going to be a
This is the code I am working from: http://jsfiddle.net/DYfbg/12/ If you click map then
Here is the code I am working from: http://jsfiddle.net/5yEGX/ I wanted to put something
I have this code: http://jsfiddle.net/gk5pV/8/ It's function is to add a td value to
I'm working with a Google Maps example code , this : http://www.wolfpil.de/v3/drag-from-outside.html which has
I have this code : http://jsfiddle.net/Qchmqs/BSKrG/ <div class=step><-- this is darned wrong <div id=step2><a>Darn</a></div>
I currently have this working fiddle - http://jsfiddle.net/B8Abd/ I would like to use jquerys
JSfiddle (showing the non-working code) here: http://jsfiddle.net/ts2Rr/ I have three boxes that a user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.