根据文档,infoWindow标记是可选的,那么请问如何实现?我试过infowindow.open(地图)和infowindow.open(map,null)但都没有产生任何东西。Google地图没有标记的infoWindow?
4
A
回答
4
infowindow.open(map)
是没有意义的,因为您需要指定infowindow应该打开的位置,还有一个锥形的茎干,它指定了它应该指向的位置。
根据Infowindows的documentation-InfoWindows可以附加到标记对象(在这种情况下,它们的位置基于标记的位置),或者在地图本身的指定LatLng上。
所以,如果你想DONOT标记打开信息窗口,使用地图点击事件 -
var iwindow= new google.maps.InfoWindow;
google.maps.event.addListener(map,'click',function(event)
{
iwindow.setContent(event.latLng.lat()+","+event.latLng.lng());
iwindow.open(map,this);
iwindow.open(map,this);
});
,并关闭一个InfowWindow- infowindow.setMap(null);
。希望清除你的疑虑。
+0
非常感谢,正是我所需要的。 – Archdeacon
+0
欢迎。 Plz考虑通过点击解决方案旁边的勾号来标记答案:) – Cdeez
5
如果位置设置,存在一个显示信息窗口
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 6,
center: {lat: 55.6761, lng: 12.5683},
mapTypeId: google.maps.MapTypeId.TERRAIN
});
var infowindow = new google.maps.InfoWindow({
content: "Copenhagen"
});
infowindow.setPosition({lat: 55.6761, lng: 12.5683});
infowindow.open(map);
}
相关问题
- 1. 在标记上添加infoWindow Google地图
- 2. 在Google地图上设置一个标记的infowindow图标
- 3. 谷歌地图标记infowindow
- 4. 当只有一个标记时,Google地图InfoWindow打开
- 5. 在Google地图中为现有标记添加infowindow API
- 6. 如何在Google地图街景视图中显示infowindow标记
- 7. 来自Google地图外部的控制标记infowindow API
- 8. 初始化离子Google地图中的标记和Infowindow
- 9. 如何设置Google地图标记的infowindow最大高度?
- 10. 在Google地图上打开标记infowindow的超链接
- 11. 在没有标记的Google Maps v3上显示InfoWindow onMouseOver
- 12. Google地图infowindow无法在标记点击上工作
- 13. Google地图:如何为自定义标记创建一个infowindow?
- 14. 如何在Google地图Subgurim中始终显示infowindow标记?
- 15. 在Google地图上打开infowindow应用启动时标记
- 16. Google地图 - 重复使用单个infoWindow获取多个标记
- 17. Google地图标记不会在Firefox上生成Infowindow
- 18. 显示infowindow的标记没有点击
- 19. Google地图标记
- 20. 标记内容(infoWindow)谷歌地图
- 21. Android地图infowindow上点击标记
- 22. 谷歌地图Infowindow在多个标记
- 23. 谷歌地图标记迭代infowindow
- 24. Swift子类Google地图infoWindow
- 25. Google地图中心和InfoWindow
- 26. InfoWindow与Google地图apı
- 27. 具有多个标记的Google地图
- 28. Google地图2 InfoWindow自动打开infoWindow,1点击后的infoWindow
- 29. Infowindow for Google Map中的圆形标记
- 30. Google地图和地图上的标记
你想要什么,并和你尝试过什么,张贴在这里的代码没有问题。 –