google map api我没什么问题。
我在此页面(https://developers.google.com/maps/documentation/javascript/examples/)之后成功嵌入了谷歌地图v.3。
现在我想在同一页面中放置一些链接,当我点击链接时,请确定地图中的位置。并且还显示我的自定义地图图钉图标。
离。
...
<a href="link to get this place's location">Blah Blah City Convention Center</a>
<a href="link to get this place's location2">Blah Blah Shopping Mall</a>
如果有人知道官方页面解释了这个或一些好的教程网站,请告诉我。
我开始使用jsfiddle页面。随意修改:)
谢谢。答案 0 :(得分:0)
当您向地图添加标记并向该标记添加事件时(将事件添加到此标记时),请使用您的超链接的地图,标记和ID调用以下方法。
function attachEvents(map, myMarker, linkID) {
var markerRelDivObj = document.getElementById(linkID);
if (markerRelDivObj) {
markerRelDivObj.onmouseover = function () {
if (!map.getBounds().contains(myMarker.getPosition())) {
map.panTo(myMarker.getPosition());
}
google.maps.event.trigger(myMarker, 'mouseover');
};
markerRelDivObj.onmouseout = function () {
google.maps.event.trigger(myMarker, 'mouseout');
};
}
}
答案 1 :(得分:0)
我在这里创建了两个链接,使地图移动和缩放。
You can <a href="#"
onclick="oMap.setCenter(new google.maps.LatLng(20, 14.2));oMap.setZoom(2);">
zoom out to see the global perspective</a>
or <a href="#"
onclick="oMap.setCenter(new google.maps.LatLng(54, -4));oMap.setZoom(6);">
see the UK here</a>
。
这假设您的脚本块已经设置了一个名为oMap
的对象。