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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:26:33+00:00 2026-06-01T08:26:33+00:00

I have map with multiple different colors markers with some info window. Everything works

  • 0

I have map with multiple different colors markers with some info window. Everything works OK except when I click on some marker (I have 5 of them on example) it switches my cursor on, let’s say, the 4-th marker and displays info window always from that marker. So it displays always the same info window.
It is small html file, so I would appreciate if someone knows the solution for this.
I tried also and with google.maps.event.addDomListener because I suppose that there is the problem but it is the same behaviour.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head> 
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> 
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
    <title>Google Maps Javascript API v3 Example: Loading the data from an XML</title> 
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
<script type="text/javascript" src="downloadxml.js"></script>

<script type="text/javascript"> 
//<![CDATA[





     // global "map" variable
      var map = null;






function initialize() {

  var myOptions = {
    zoom: 8,
    center: new google.maps.LatLng(43.907787,-79.359741),
    mapTypeControl: true,
    mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
    navigationControl: true,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  map = new google.maps.Map(document.getElementById("map_canvas"),
                                myOptions);

  google.maps.event.addListener(map, 'click', function() {
        infowindow.close();
        });
      // Read the data from example.xml
      downloadUrl("example7.xml", function(doc) {
        var xmlDoc = xmlParse(doc);
        var markers = xmlDoc.documentElement.getElementsByTagName("marker");
        for (var i = 0; i < markers.length; i++) {
          // obtain the attribues of each marker
          var lat = parseFloat(markers[i].getAttribute("lat"));
          var lng = parseFloat(markers[i].getAttribute("lng"));
          var point = new google.maps.LatLng(lat,lng);
          var html = markers[i].getAttribute("html");




        var severity = parseFloat(markers[i].getAttribute("severity"));

        var color= "66FF33";


       if (severity == 0) color = "66FF33";
       else if (severity == 1) color = "990099";
        else if (severity == 2) color = "00CCFF";


        var pinImage = new google.maps.MarkerImage("http://www.googlemapsmarkers.com/v1/" + color,
        new google.maps.Size(21, 34),
        new google.maps.Point(0,0),
        new google.maps.Point(10, 34));


      var marker = new google.maps.Marker({
                position: point,
                map: map,
                icon: pinImage,

            });

 google.maps.event.addListener(marker, 'click', function() {
        var alarmanchor1='<span class="url"><a href="' + html;
        var alarmanchor2='" title="www" target="_blank">Event List</a></span>';
        var contentString=alarmanchor1+alarmanchor2;
        infowindow.setContent(contentString); 
        infowindow.open(map,marker);
        });




        }

      });
    }

var infowindow = new google.maps.InfoWindow(
  { 
    size: new google.maps.Size(150,50)
  });


//]]>
</script> 

  </head> 
<body style="margin:0px; padding:0px;" onload="initialize()"> 


    <table border="1"> 
      <tr> 
        <td> 
           <div id="map_canvas" style="width: 1050px; height: 1200px"></div> 
        </td> 

      </tr> 
    </table> 


<script src="urchin.js" type="text/javascript"> 
</script> 


  </body> 
</html> 

My XML is:

<markers>

 <marker lat="43.65654" lng="-79.90138" html="http://www.google.com"  label="Marker One" severity="0" />
 <marker lat="43.91892" lng="-78.89231" html="http://www.yahoo.com" label="Marker Two" severity="1" />
 <marker lat="43.82589" lng="-79.10040" html="http://www.sport.com"  label="Marker Three" severity="2" />
  <marker lat="43.72589" lng="-79.60040" html="http://www.stackoverflow.com"  label="Marker Fourth" severity="3" />
   <marker lat="43.52589" lng="-79.70040" html="http://www.stackoverflow.com"  label="Marker Five" severity="4" />
 </markers> 
  • 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-01T08:26:35+00:00Added an answer on June 1, 2026 at 8:26 am

    Just change your code to this so that it gets the correct url for each element.

    <a href="' + html;
    

    to

    <a href="' +markers[i].getAttribute("html");
    

    so the full code to your question is:

    google.maps.event.addListener(marker, 'click', (function(marker, i) { return function(){ var alarmanchor1='<span class="url"><a href="' +markers[i].getAttribute("html"); var alarmanchor2='" title="www" target="_blank">Event List</a></span>'; var contentString=alarmanchor1+alarmanchor2; infowindow.setContent(contentString); infowindow.open(map, marker); } }) (marker, i));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im making an map with different markers which should have different info windows. But
Is it preferred to have one depot with multiple folders which map to different
I have a map with multiple markers, which I populate via an array. Each
How should I map multiple columns with List in IBATIS ? I have a
I have a std::map that is used by multiple threads to store data. The
I have a fairly unique situation trying to map a single table to multiple
I'm trying to insert multiple times this same key into map but with different
Our ldap is set up so that we have multiple different organizational units (ou).
I have a service that generates a large map through multiple iterations and calculations
I have a downloader function that downloads multiple files parallely. I use multiprocessing.Pool.map_async in

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.