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

  • Home
  • SEARCH
  • 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 3305252
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:08:51+00:00 2026-05-17T21:08:51+00:00

Having similar problem as others have had on this website where it shows only

  • 0

Having similar problem as others have had on this website where it shows only the last marker’s info window info in all markers. Can’t seem to solve this with any of the solutions given. Also, the last one of my markers doesn’t show an info window at all.

<script src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="data2.json"></script>
<script type="text/javascript" src="js/markerclusterer.js"></script>

<script type="text/javascript">
  google.load('maps', '3', {
    other_params: 'sensor=false'
  });
  google.setOnLoadCallback(initialize);

  function initialize() {

var center = new google.maps.LatLng(55.4419, -4.1419);

var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 5,
      center: center,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });


var markers = [];
for (var i = 0, dataPhoto; dataPhoto = data.markers[i]; i++) {
      var latLng = new google.maps.LatLng(dataPhoto.latitude,dataPhoto.longitude);
      var theTitle = dataPhoto.address;
      var contentString = '<div align="left"><img src="logo.gif" alt="" width="242" height="71" /><br /><br /><p style="color:#000000;">' + data.markers[i].address + '<br />' + dataPhoto.telephone + '</p></div>';



      var infowindow = new google.maps.InfoWindow({
        content: contentString,
        });



    var thisIcon = 'markers/image.png';


                for (var i = 0, marker; marker = markers[i]; i++) {google.maps.event.addListener(marker, 'click', function() {infowindow.open(map,this);});
      } 


      var marker = new google.maps.Marker({
        position: latLng,
        clickable: true,
        title: theTitle,
        icon: thisIcon,
      });

      markers.push(marker);
    }
    var markerCluster = new MarkerClusterer(map, markers);


  }


</script>

Any help much appreciated!

  • 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-17T21:08:52+00:00Added an answer on May 17, 2026 at 9:08 pm

    I have not tested this but it should work – also please have a look at : http://code.google.com/apis/maps/documentation/javascript/events.html#EventClosures

    <script src="http://www.google.com/jsapi">
    </script>
    <script type="text/javascript" src="data2.json">
    </script>
    <script type="text/javascript" src="js/markerclusterer.js">
    </script>
    <script type="text/javascript">
        google.load('maps', '3', {
            other_params: 'sensor=false'
        });
        google.setOnLoadCallback(initialize);
    
        function initialize(){
    
            var center = new google.maps.LatLng(55.4419, -4.1419);
    
            var map = new google.maps.Map(document.getElementById('map'), {
                zoom: 5,
                center: center,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            });
    
    
            var markers = [];
            for (var i = 0, dataPhoto; dataPhoto = data.markers[i]; i++) {
                var latLng = new google.maps.LatLng(dataPhoto.latitude, dataPhoto.longitude);
                var theTitle = dataPhoto.address;
                var contentString = '<div align="left"><img src="logo.gif" alt="" width="242" height="71" /><br /><br /><p style="color:#000000;">' + data.markers[i].address + '<br />' + dataPhoto.telephone + '</p></div>';
                var thisIcon = 'markers/image.png';
                var marker = new google.maps.Marker({
                    position: latLng,
                    clickable: true,
                    title: theTitle,
                    icon: thisIcon,
                });
    
                attachIWindow(contentString, marker);
    
    
                markers.push(marker);
            }
            var markerCluster = new MarkerClusterer(map, markers);
    
    
        }
    
        function attachIWindow(content, marker){
    
    
            var infowindow = new google.maps.InfoWindow({
                content: content,
    
            });
            google.maps.event.addListener(marker, 'click', function(){
                infowindow.open(map, marker);
            });
        }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with Gridview sorting that is similar to others but I'm
I'm wondering if this is something somewhat simple, but I'm having a problem ONLY
I wrote this code because I'm having a similar problem in a larger program
I am having a similar issue to this person . The primary difference being
Having this route: map.foo 'foo/*path', :controller => 'foo', :action => 'index' I have the
I've been going at this problem for a solid couple hours now and having
I have seen many others with similar problems but I cannot find the flaw
I am having a problem with the following query(if this is a duplicate question
This problem has been bothering me for sometime now, I have not settled on
I've been searching all day and found several similar issues, but none have resolved

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.