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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:38:44+00:00 2026-05-21T16:38:44+00:00

I started to list my markers individually for my Google Map, but quickly realised

  • 0

I started to list my markers individually for my Google Map, but quickly realised this was
inefficient. I have tried to create an array to put the markers onto my map, but it is not showing anything, can you see where I have gone wrong?

function initialize() {
        var latlng = new google.maps.LatLng(52.474, -1.868);

        var myOptions = {
            zoom: 11,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };

        var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
        var image = 'i/hotel-map-pin.png';

        var hotels = [
            ['ibis Birmingham Airport', 52.452656, -1.730548, 4],
            ['ETAP Birmingham Airport', 52.452527, -1.731644, 3],
            ['ibis Birmingham City Centre', 52.475162, -1.897208, 2]
        ];

        for (var i = 0; i < hotels.length; i++) {
            var marker = new google.maps.Marker({
                position: hotels[1],
                map: map,
                icon: image,
                title: hotels[0],
                zIndex: hotels[2]
            });
        }
    }

Thanks.

  • 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-21T16:38:45+00:00Added an answer on May 21, 2026 at 4:38 pm

    In your loop you are accessing the hotels array at fixed indexes (1, 0 & 2) rather than the array elements at index i:

      for (var i = 0; i < hotels.length; i++) {
            var hotel = hotels [i]
            var marker = new google.maps.Marker({
                position: new google.maps.LatLng (hotel[1], hotel[2]),
                map: map,
                icon: image,
                title: hotel[0],
                zIndex: hotel[3]
            });
        }
    

    Here is a working example with the fix.

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

Sidebar

Related Questions

I have tried to implement doubly linked list in C++. Here is the code,
I started an application in Google App Engine right when it came out, to
This is a question-loaded post from someone who is just getting started with BB
I have a groovy list of lists i.e. list = [[2, 0, 1], [1,
In my application, I have 2 list activities which can start one or the
Lately we've started getting issues with outdated countries / regions list being presented to
I started using Python in 2001. I loved the simplicity of the language, but
Hello i have just started learning mvc2 and im having a problem with the
I have started some hands on in Erlang and I am getting : **
I have trouble getting started with rails 3.0.0, because it just doesn't load the

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.