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 8201453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:49:14+00:00 2026-06-07T06:49:14+00:00

I modified the javascript from https://google-developers.appspot.com/maps/documentation/javascript/examples/geocoding-simple to var geocoder; var postalArr = []; postalArr.push(249586);

  • 0

I modified the javascript from https://google-developers.appspot.com/maps/documentation/javascript/examples/geocoding-simple to

var geocoder;
var postalArr = []; 
postalArr.push(249586);
postalArr.push(266751);
var map;

function initialize(){

 var myLatlng = new google.maps.LatLng(1.3667, 103.7500);
   var myOptions = {
     zoom: 13,
     center: myLatlng,
     mapTypeId: google.maps.MapTypeId.ROADMAP,
   };

  if (postalArr) {
      for (var i = 0; i < postalArr.length; i++ ) {
        codeAddress(postalArr[i]);
     }
  }

  map = new google.maps.Map(document.getElementById('map_canvas'),
      myOptions);  
}

function codeAddress(postal) {
    geocoder.geocode( { 'postal': postal}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        map.setCenter(results[0].geometry.location);
        var markerE = new google.maps.Marker({
            map: map,
            position: results[0].geometry.location,
        });
      } else {
        alert("Geocode was not successful for the following reason: " + status);
      }
    });

The script goes within the for loop but doesn’t run the codeAddress function.
I’m not sure why.

  • 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-07T06:49:17+00:00Added an answer on June 7, 2026 at 6:49 am

    Two things.

    (1) need to define geocoder somewhere, I put it in the initialize

    function initialize(){
      geocoder = new google.maps.Geocoder();
    

    (2) there’s no such thing as a postal property to feed the geocoder. Valid requests are for a latlng or an address as explained here.

    So at least you must specify a country. I’m not sure what country 249586 is for, in my demo I used two California zip codes, and added “, United States” to the address.

    geocoder.geocode( { 'address': postal + ", United States"}, 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I modified this simple countdown timer form here: https://github.com/lunaryorn/snippets/blob/master/qt4/countdown.py as follows. Now I want
I'm javascript newbie...please bear with me. Modified some jQuery animation code from w3c tutorial.
I have the following javascript code, which is modified from the SimpleUpload demo in
I have the following modified code from google that displays a map with polygons
I've got a markup as follows (code modified from http://jsfiddle.net/nick_craver/srg6g/ ): <div id=maps> <div
The static html pages of my project has javascript dynamically modified content and that
I am using the Syntax Highlighter built with Javascript by Alex Gorbatchev (http://alexgorbatchev.com/SyntaxHighlighter/download/) The
Using FullCalendar ( http://arshaw.com/fullcalendar/ ) to pull events from a MySQL database table via
I want to read plain/text from an Https server. I have tried various codes
In rhino, I'm used to being able to load javascript libraries from a URL,

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.