Google maps-api v3 InfoWindow会在页面加载时自动打开 [英] Google maps-api v3 InfoWindow automatically open on page load

查看:127
本文介绍了Google maps-api v3 InfoWindow会在页面加载时自动打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google Maps api-v3,
的项目进行工作。在地图上会有几个地方标记,其中包含我存储在InfoWindow中的信息。



我想知道有没有办法可以设置InfoWindow在页面加载时自动打开(即自动打开,无需用户交互)。

在网上搜索我所能找到的所有东西都需要绑定到一个事件监听器,但InfoWindow对象似乎有的所有事件都是鼠标事件。



有谁知道各种解决方法?

解决方案

不确定我是否完全理解您的问题,但这适用于硬编码的LatLng:

  var infoWindow = null; 
函数initialize()
{
infoWindow = new google.maps.InfoWindow();
var windowLatLng = new google.maps.LatLng(43.25,-68.03);
infoWindow.setOptions({
content:< div>这是html内容。< / div>,
位置:windowLatLng,
});
infoWindow.open(map);
} //结束初始化

google.setOnLoadCallback(initialize);


I am working on a project where I am using the Google Maps api-v3 , On the map there will be a few place markers containing information that I am storing in an InfoWindow.

I am wondering is there anyway that you can set an InfoWindow to automatically open on the page load (i.e automatically open without user interaction).

Searching online all I can seem to find is that it needs to be tied to an event listener but all the events the InfoWindow object seems to have are mouse events.

Does anyone know of a workaround of sorts ?

解决方案

Not sure I fully understand your question but this works for me with a hard-coded LatLng:

var infoWindow = null;
function initialize() 
{
    infoWindow = new google.maps.InfoWindow();
    var windowLatLng = new google.maps.LatLng(43.25,-68.03);
    infoWindow.setOptions({
        content: "<div>This is the html content.</div>",
        position: windowLatLng,
    });
    infoWindow.open(map); 
} // end initialize

google.setOnLoadCallback(initialize);

这篇关于Google maps-api v3 InfoWindow会在页面加载时自动打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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