在google maps api v3中修改信息窗口中的内容 [英] Modifying content within info-window in google maps api v3

查看:83
本文介绍了在google maps api v3中修改信息窗口中的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在地图上显示4个标记,并且所有信息的infowindows都包含唯一字符串数组和字符串旁边的图像。

我的问题是,我试图每分钟更改一次图片,并且只有当我打开信息窗口时才会更改,然后只有该信息窗口才会更改关闭那些不会更新。



这里是用来更新它的方法:

  setInterval (更新,1000 * 60); (var j = 0; j< data [b])的

函数update(){
for(var i = 0; i< data.length; i ++) 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'/>);
//班级图像的类别被放入
}
}
}

我只是寻找一些建议,如果我可以修改关闭的信息窗口内的数据。



我只想提及我不是在寻找代码,而是寻求一些建议。



谢谢您提前

解决方案

如果您有权访问它,可以更改已关闭InfoWindows中的内容。一种选择是将HTML(或创建HTML所需的信息)存储在标记的成员变量中。使用该信息在InfoWindow在点击时打开时填充InfoWindow。您可以随时更改该信息;对于当前打开的infowindow中的信息,您必须通过修改DOM来完成此操作。

请参阅这个类似的问题的答案


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

解决方案

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.

这篇关于在google maps api v3中修改信息窗口中的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆