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

having an observable array like so: this.list = ko.observableArray([ new GoalItem(1, 'page', 'Getting started',
I need to re-format a list of UK postcodes and have started with the
I have tried to implement doubly linked list in C++. Here is the code,
Hi I started programming a ToDo-List on android (in eclipse) which synchronises with Google
Very basic question here (I've just started with Python). I have a list object.
I started to create a todo list with jQuery mobile in order to learn
Here's a list I've started, and would like to complete. I'm looking to create
I just started learning Python today. I have a list: [text:u'Oranges', text:u'Apples', empty:'', empty:'']
The background color of <ol > list is not displayed properly. This problem started
I have just started using PowerShell today, and I have an intention list files

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.