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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:54:49+00:00 2026-05-28T18:54:49+00:00

I’m new with Google map. I’m having problem in rebinding the data in my

  • 0

I’m new with Google map. I’m having problem in rebinding the data in my infowindow.

When I close the window using the "x" button in the upper right of the infowindow,
then open it again, all of the updated contents of the infowindow will load again to
its initial state instead of the latest update? What I want is that when I close the
infowindow, the infowindow must have the latest data.

<!DOCTYPE html >
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>PHP/MySQL & Google Maps Example</title>

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="D:\Program Files\xampp\xampp\htdocs\googletest\progressBar.js"></script>
<script type="text/javascript">

//<![CDATA[

var infoWindow=new Array();
var htmlPrevious=new Array();
var html;
var marker=new Array();

function load() {
    var map = new google.maps.Map(document.getElementById("map"), {
    center: new google.maps.LatLng(7.11425, 124.83758),
    zoom: 11,
    mapTypeId: 'roadmap'
});
  
downloadUrl("phpsqlajax_genxml.php", function(data) {
    var xml = data.responseXML;
    var markers = xml.documentElement.getElementsByTagName("marker");
    html = new Array(markers.length);
    infowindow = new Array(markers.length);
    
    for (var i = 0; i < markers.length; i++) {
        infoWindow[i] = new google.maps.InfoWindow;
        var sender = markers[i].getAttribute("sender");
        var update = markers[i].getAttribute("update_time");
        var name = markers[i].getAttribute("name");
    var humidity = markers[i].getAttribute("humidity");
    var temperature = markers[i].getAttribute("temperature");
    var rain = markers[i].getAttribute("rain");
        var wind_dir = markers[i].getAttribute("wind_dir");
    var wind_speed = markers[i].getAttribute("wind_speed");
    var image = markers[i].getAttribute("image");
        var point = new google.maps.LatLng(
          parseFloat(markers[i].getAttribute("lat")),
          parseFloat(markers[i].getAttribute("lng")));
      
          
        html[i] = "<div style='display:block;' width='600' height='300' overflow='hidden'><img style='display:block;' src='"+image+" ' width='300' height='184' /> <br/><b>" + name + "</b> <br/>Sender: " + sender + "<br/>Time: " + update + "<br/> Humidity: " + humidity + "<br/>Temperature: " + temperature + "<br/>Rain: " + rain + "<br/>Wind Direction:   " + wind_dir + "<br/>Wind Speed: " + wind_speed + "<div>";
      
     
      htmlPrevious[i]=html[i];
      
       marker[i] = new google.maps.Marker({
        map: map,
        position: point,
    title: name 
      });
    
      bindInfoWindow(marker[i], map, infoWindow[i], html[i]);
      
    }//end for loop
  });//downloadurl
  setInterval("refreshMarker()",1000);
}

function refreshMarker(){
    downloadUrl("phpsqlajax_genxml.php", function(data) {
    var xml = data.responseXML;
    var markers = xml.documentElement.getElementsByTagName("marker");
    
    for (var i = 0; i < markers.length; i++) {
      var sender = markers[i].getAttribute("sender");
      var update = markers[i].getAttribute("update_time");
      var name = markers[i].getAttribute("name");
      var humidity = markers[i].getAttribute("humidity");
      var temperature = markers[i].getAttribute("temperature");
      var rain = markers[i].getAttribute("rain");
      var wind_dir = markers[i].getAttribute("wind_dir");
      var wind_speed = markers[i].getAttribute("wind_speed");
      var image = markers[i].getAttribute("image");
      var point = new google.maps.LatLng(
          parseFloat(markers[i].getAttribute("lat")),
          parseFloat(markers[i].getAttribute("lng")));
    
       html[i] = "<div style='display:block;' width='600' height='300' overflow='hidden'><img style='display:block;' src='"+image+" ' width='300' height='184' /> <br/><b>" + name + "</b> <br/>Sender: " + sender + "<br/>Time: " + update + "<br/> Humidity: " + humidity + "<br/>Temperature: " + temperature + "<br/>Rain: " + rain + "<br/>Wind Direction:   " + wind_dir + "<br/>Wind Speed: " + wind_speed + "<div>";
       

        if (html[i]!=htmlPrevious[i]){
        htmlPrevious[i]=html[i];
        
    
        
    infoWindow[i].setContent(html[i]);
        
        google.maps.event.addListener(marker, 'click', function() {
        infoWindow[i].set("marker",null);
        infoWindow[i].close();
           bindInfoWindow(marker[i], map, infoWindow[i], html[i]);
           infoWindow[i]=infoWindow;
  });
        }
        //infoWindow.open(map, marker);
    

    }
  });
}

function bindInfoWindow(marker, map, infoWindow, html) {
  google.maps.event.addListener(marker, 'click', function() {
    infoWindow.setContent(html);
    infoWindow.open(map, marker);
    alert("imhere");
  });
}

function closeInfoWindow(marker, map, infoWindow, html) {
  google.maps.event.addListener(marker, 'closeclick', function() {
    infoWindow.close();
    alert("im here");
  });
}

function downloadUrl(url, callback) {
  var request = window.ActiveXObject ?
      new ActiveXObject('Microsoft.XMLHTTP') :
      new XMLHttpRequest;

  request.onreadystatechange = function() {
    if (request.readyState == 4) {
      request.onreadystatechange = doNothing;
      callback(request, request.status);
    }
  };

  request.open('GET', url, true);
  request.send(null);
}

function doNothing() {}

//]]>

</script>
</head>

<body onload="load()">
    <div id="map" style="width: 1330px; height: 610px"></div>
</body>

</html>

Any help will highly 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-28T18:54:50+00:00Added an answer on May 28, 2026 at 6:54 pm

    Update your function to be:

    function bindInfoWindow(marker, map, infoWindow, html) {
        google.maps.event.addListener(marker, 'click', function() {
             infoWindow.setContent(html);
             infoWindow.open(map, marker);
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.