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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:06:30+00:00 2026-05-13T11:06:30+00:00

I am trying to add markers onto a google map to identify the states

  • 0

I am trying to add markers onto a google map to identify the states using:

function initialize() {
 var map = new GMap2(document.getElementById("map_canvas"));
 map.setCenter(new GLatLng(-25.641526,134.472656), 4);
 map.setMapType(G_NORMAL_MAP);
 map.setUIToDefault();

var states =["-35.083236,138.503909","-24.607069,144.667969","-18.229351,133.417969","-24.686952,123.574219","-32.398516,146.953125","-35.46067,149.150391","-37.020098,143.701172","-42.682435,146.733398"]; 
  for (i = 0; i == states.length; i++) {
  var point = new GLatLng(parseFloat(states[i]));
  map.addOverlay(new GMarker(point));
  }
}

But no markers come up when I load the map (which loads fine, properly centered and of the correct map type). What am I doing wrong here?

EDIT: I changed it to this and now it works:

var lats =[-35.083236,-24.607069,-18.229351,-24.686952,-32.398516,-35.46067,-37.020098,-42.682435];
var longs =[138.503909,144.667969,133.417969,123.574219,146.953125,149.150391,143.701172,146.733398];

for (i = 0; i <= lats.length; i++) {
var point = new GLatLng(lats[i],longs[i]);
map.addOverlay(new GMarker(point));
  • 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-13T11:06:31+00:00Added an answer on May 13, 2026 at 11:06 am

    It looks like a typo in your for loop. Try it as follows:

    for (i = 0; i < states.length; i++) {
    

    Also note the float problem that Tomas pointed out.

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

Sidebar

Related Questions

I'm trying to add markers to a map on my page using Google's Javascript
I am trying to add multiple google markers on a map and I am
Am trying to add 2-way bindings between event listeners on Google Map V3 markers
I am trying to add markers to a google map created after an ajax
I'm trying to add markers to a Google maps using V3. I have my
I'm trying to add infoWindow's to multiple markers on a Google Map. The closest
I am trying to add a bunch of map markers to a map using
I am trying to add infowindows to markers/pushpins on the map. ATM, it is
NOTE: I'm using v3 of the Google Maps API I'm trying to add an
I'm trying to add markers on my Google Maps V3. I want to have

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.