0

完整的新手问题,但我无法弄清楚如何做到这一点:

http://www.warrensbakery.co.uk/plymouth.htm

我想创建一个带有跳转到谷歌地图上正确图钉并显示地址的链接的地图。

先感谢您

4

1 回答 1

1

我制作了一个包含多个位置的自定义 Google 地图地图,每个位置都可以单击地图上的图钉本身,然后会打开一个信息窗口。我还想要我相信你在谈论的东西——点击地图外的链接并在地图上打开特定图钉的信息窗口的能力。这实际上很简单 - 只需将点击事件设置为 pin 具有的相同打开 infowindow 事件。

相关的 JavaScript

/* Used variables
  map = the map itself
  marker = the current pin
  infowindow = the infowindow shown on the map
    - my setup has only one infowindow and clicks just swap its content
  label = the current infowindow content
*/


// Inside loop setting each pin to the map

// Click mevent for pins
google.maps.event.addListener(marker, 'click', function() {
    infowindow.close;
    infowindow.setContent(label);
    infowindow.open(map,marker);
});

// Click event for link outside the map
$(relevantLink).click(function(){
    $("html, body").animate({scrollTop:$("#yourMap").offset().top}, 500);
    infowindow.close();
    infowindow.setContent(label);
    infowindow.open(map,marker);
    return false;
});
于 2012-07-06T19:45:38.423 回答