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

  • Home
  • SEARCH
  • 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 7192477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:56:54+00:00 2026-05-28T19:56:54+00:00

I am very new to javascript and I am having issues with timing out

  • 0

I am very new to javascript and I am having issues with timing out the geocoder requests.
But I am stuck, I tries to add delays into loop, but seems like they don’t work.
If you can help, I would appreciarte it.

        <script type="text/javascript">

        function setLocationOnMap(locs) {
            var myOptions = {
                zoom: 4,
                center: new google.maps.LatLng(locs.lat(), locs.lng()),
                mapTypeId: google.maps.MapTypeId.ROADMAP          
            };
            var map = new google.maps.Map(document.getElementById('map_canvas'), myOptions); 

            var i=0;
            var total='<?php echo $counter ?>';

            for (i=0; i<total;i++){//adding cities to map by
                var city= document.the_form.elements[i].value;

                getLatLong2(city, map, setPointer);
            }                
        }

        function setPointer(map, address, locs2){
            var position = new google.maps.LatLng(locs2.lat(), locs2.lng());
            var marker = new google.maps.Marker({
                position: position,
                map: map
            });
            marker.setTitle(address);
        }


        function initialize() {
            var address = "Chicago IL";
            getLatLong(address, setLocationOnMap);
        }

        function getLatLong2(address, map, callback){
            var geo = new google.maps.Geocoder;
            geo.geocode({'address':address},function(results, status){
                if (status == google.maps.GeocoderStatus.OK) {
                    locs2 = results[0].geometry.location; 

                    callback(map, address, locs2);
                } else {
                    //alert("Geocode was not successful for the following reason: " + status);
                }
            });
        }



        function getLatLong(address, callback){
            var geo = new google.maps.Geocoder;
            geo.geocode({'address':address},function(results, status){
                if (status == google.maps.GeocoderStatus.OK) {
                    // processing...
                    locs = results[0].geometry.location; 
                    //pausecomp(10000);

                    callback(locs);
                } else {
                    //alert("Geocode was not successful for the following reason: " + status);
                }
            });
        }
    </script>
  • 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-05-28T19:56:55+00:00Added an answer on May 28, 2026 at 7:56 pm

    When you submit the geocode request, you can start a timer in parallel and when the timer fires, you can declare the request to have timed out. The request will still continue, but you can ignore the results once it has timed out:

    function getLatLong(address, callback){
        var timerId;
        var timedOut = false;
    
        var geo = new google.maps.Geocoder;
        geo.geocode({'address':address},function(results, status){
            if (timedOut) {
                // this request timed out, so ignore results
                return;
            } else {
                // this request succeeded, so cancel timer
                clearTimeout(timerId);
            }
    
            if (status == google.maps.GeocoderStatus.OK) {
                locs = results[0].geometry.location; 
                callback(locs);
            } else {
                //alert("Geocode was not successful for the following reason: " + status);
            }
        });
    
        timerId = setTimeout(function() {
            timedOut = true;
            alert('Request timed out.');
            // do something else
        }, 10000);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a bit new to programming in jQuery/Javascript and am having some issues
I am still new at PHP/Javascript/Ajax and am having a very hard time (been
I'm very new to both the Mvc framework as well as JavaScript and JQuery.
I am very new at jQuery ... I've used Javascript many times and am
I noticed that JavaScript's new Date() function is very smart in accepting dates in
Very new to FluentNHibernate, but I'm also excited about the area. I've recently started
Im very new to SQL but need to write a query to do the
Yes, I am having issues with this very basic (or so it seems) thing.
I am very new in Struts 2. I am having three text-fields in my
I am new to javascript and I am trying to start a very simple

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.