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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:55:13+00:00 2026-06-14T14:55:13+00:00

I have a map that uses infoBubble.js. In this map there is an array

  • 0

I have a map that uses infoBubble.js.

In this map there is an array of locations that I iterate through.

The infoBubble should pop up when the custom icon is clicked but for some reason it only ever opens up the first data item.

Does anyone have an idea as to why that may happen?

I have developed the code for it here;

var arrMarkers = [
    ['Santiago de Cuba', 20.040450354169483, -75.8331298828125],
    ['Las Tunas', 20.97682772467435, -76.9482421875],
    ['Camaguey', 21.39681937408218, -77.9205322265625],
    ['Playa Santa Lucia', 21.555284406923192, -77.0526123046875],
    ['Santa Clara', 22.421184710331854, -79.9639892578125],
    ['Cienfuegos', 22.161970614367977, -80.4473876953125],
    ['Havana', 23.12520549860231, -82.3919677734375],
    ['San Cristobel', 22.730590425493833, -83.045654296875],
    ['Pinar del Rio', 22.43641760076311, -83.69384765625]
];

var arrInfoWindowsCuba = [];

var arrInfoWindows = [];
arrMarkers[i] = marker;

function init() {

    var mapCenter = new google.maps.LatLng(21.616579336740603, -78.892822265625);
    map = new google.maps.Map(document.getElementById('map_canvas'), {
        zoom: 7,
        center: mapCenter,
        mapTypeId: google.maps.MapTypeId.TERRAIN
    });
    var image = '/wp-content/themes/Shootcuba/images/map-icon.png';

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


        var infoBubble = new InfoBubble({
            content: '<div class="phoneytext">' + arrMarkers[i][0] + '<div class="left-col2"></div></div>',
            boxClass: 'info-box',
            alignBottom: true,
            pixelOffset: new google.maps.Size(-150, -40),
            maxWidth: 300,
            padding: 0,
            closeBoxMargin: '0px',
            borderColor: '#ffffff',
            borderRadius: '0',
            maxWidth: 535,
            disableAutoPan: false,
            hideCloseButton: false,
            backgroundClassName: 'phoney'
        });
        google.maps.event.addListener(marker, 'click', function () {
            infoBubble.open(map, marker, i);
            console.log(arrMarkers);
        });

        arrMarkers[i] = marker;
        arrInfoWindowsCuba[i] = infoBubble;

    }
}
  • 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-14T14:55:14+00:00Added an answer on June 14, 2026 at 2:55 pm

    Here’s a working example. I took out a few of the arrays you had (I wasn’t entirely sure what they were all for, and they were causing errors in just the snippet you posted), but otherwise is pretty true to what you were doing. The big difference is that I made a separate function for creating the markers. This was mainly done to keep the scope of the click events separate from one another, since the click event always triggering the last event indicates to me that the scopes aren’t properly separate.

    In particular, what I believe was happening is that the event function you kept overriding values to marker and infoBubble, and the event listener would refer to the current values of those variables, not the values when you first attach the listener. Making a separate function call to maintain the scope for the events strikes me as the cleanest solution.

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

Sidebar

Related Questions

I have a Map that uses a Set for the key type, like this:
Is there some implementation of java.util.Map that does not uses HashCode? I have the
I have image map that can I move, but this map will be so
I have a a map that looks like this: public class VerbResult { @JsonProperty("similarVerbs")
I have a html map that uses world map image as its background. I
I have a Google Map API v3 map object on a page that uses
I am developing sample application that uses Google Map API. I have generated Google
I have an intranet web app that uses CSS httpFolder to map a webdav
I have an application that uses the mapview-overlay-manager code to draw map markers on
I have an image map that uses a third party script(mapper.netzgesta.de) to highlight 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.