【问题标题】:Is it possible to open multiple infoWindows for one marker in google maps api?是否可以在 google maps api 中为一个标记打开多个 infoWindows?
【发布时间】:2016-07-26 20:27:19
【问题描述】:

我正在做一个项目,他们希望这样查看信息窗口:

[![在此处输入图片描述][1]][1]

这怎么可能?你会推荐哪个库?

【问题讨论】:

  • 问题是您想要一个标记或多个标记的多个信息窗口?
  • 一个标记的多个信息窗口
  • 我看到只有 1 个元素我称之为“InfoWindow” ....红色框可以通过自定义覆盖实现(例如 InfoBox),其他框通过 custom controls
  • 右边的白色元素也将是一个信息窗口,显示有关标记的更多信息。
  • @Dr.Molle 你用过 infoBox 吗?因为缩放时它的位置不同..

标签: javascript google-maps google-maps-markers infowindow


【解决方案1】:

在 Google maps v3 中,可以通过创建自定义事件侦听器和修改自动居中来实现。示例可以在这里找到:http://you.arenot.me/2010/06/29/google-maps-api-v3-0-multiple-markers-multiple-infowindows/

一个标记的多个信息窗口(未测试):

var infowindow = new google.maps.InfoWindow();
var infowindow2 = new google.maps.InfoWindow();
var marker = new google.maps.Marker({
  position:latLng,
  map: map
});

google.maps.event.addListener(marker, 'click', function(content){
  return function(){
    infowindow.setContent(content);
    infowindow.open(map, this);
    infowindow2.setContent(content+'222');
    infowindow2.open(map, this);
  }
}(content));

【讨论】:

    猜你喜欢
    • 2012-06-21
    • 1970-01-01
    • 1970-01-01
    • 2015-05-02
    • 1970-01-01
    • 1970-01-01
    • 2012-08-27
    • 2013-06-19
    • 2012-05-25
    相关资源
    最近更新 更多