最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Modifying content within info-window in google maps api v3 - Stack Overflow

programmeradmin2浏览0评论

I have 4 markers being displayed on a map and the infowindows of the all contain an array of unique strings and an image next to the string.

my problem is that I'm trying to change the images every minute and they change only if i have the info window open and then only that info window will change the closed ones will not update.

here is the method im using to update it:

setInterval(update, 1000 * 60);

function update(){
  for(var i = 0; i < data.length; i++){
    for(var j = 0; j < data[i].test.length; j++){
        var test = data[i].test[j];
        test = test.replace(/ /g, '');
        test = test.replace(/[-]/g,'');
        test = test.replace(/[()]/g, '');
        $('.'+test).html("<img src='Images/red.gif' />");
        //class of the span image is being placed into
    }
  }
}

I'm just looking for some advice on if i can modify the data within the closed info windows.

I'd just like to mention I'm not looking for code but just some advice.

Thank you in advance

I have 4 markers being displayed on a map and the infowindows of the all contain an array of unique strings and an image next to the string.

my problem is that I'm trying to change the images every minute and they change only if i have the info window open and then only that info window will change the closed ones will not update.

here is the method im using to update it:

setInterval(update, 1000 * 60);

function update(){
  for(var i = 0; i < data.length; i++){
    for(var j = 0; j < data[i].test.length; j++){
        var test = data[i].test[j];
        test = test.replace(/ /g, '');
        test = test.replace(/[-]/g,'');
        test = test.replace(/[()]/g, '');
        $('.'+test).html("<img src='Images/red.gif' />");
        //class of the span image is being placed into
    }
  }
}

I'm just looking for some advice on if i can modify the data within the closed info windows.

I'd just like to mention I'm not looking for code but just some advice.

Thank you in advance

Share Improve this question asked Dec 6, 2012 at 18:56 Roy James SchumacherRoy James Schumacher 6462 gold badges11 silver badges27 bronze badges 1
  • Possible duplicate of Changing the Google Maps Marker HTML after a function is ran – Danish Adeel Commented May 15, 2016 at 9:09
Add a ment  | 

1 Answer 1

Reset to default 4

You can change the content in the "closed" InfoWindows if you have access to it. One option would be to store the HTML (or the info required to create the HTML) in member variables of the marker. Use that information to populate the InfoWindow when it is opened on click. You can change that information at any time; for information in the currently open infowindow, you will have to do that by modifying the DOM.

See the answer to this similar question.

发布评论

评论列表(0)

  1. 暂无评论