0

我看过一些涉及类似主题的帖子,但还不够接近,无法申请到我的网站。在此页面上加载地图时,我希望打开某个信息窗口:http ://www.wrh.noaa.gov/mfr/rec 。

我想传递一个 url 参数(我已经这样做了用于缩放、中心等),它将打开一个特定的 infowindow onload 而不会更改页面的整体功能(如果没有为 infowindow 传递 url 参数)。

谢谢你的帮助。我想我必须做一些编辑 b/c 我在 infowindow 上显示了多个变量(与 xml 元素相关联......我从我的 xml 文档中获取了标记的大部分内容)和在带有预报的地图下方。


我认为我的问题并不完全清楚。我会改写:肖恩,非常感谢。我不想只打开一个信息窗口来创建另一个网页,我认为这就是您的建议。我有客户希望我的地图放大,只显示一个娱乐站点(标记),信息窗口打开,并在页面下方显示预测。这是我想要的示例(设置缩放和中心值的 url 参数),但我无法打开地图中显示的唯一标记的信息窗口。例如,如果我可以编写这样的 URL:http ://www.wrh.noaa.gov/mfr/rec/index.php?t=roadmap&lat=42.10053453772226&lng=-123.40782557983397&z=12&window=oregoncaves 将显示放大的地图并打开信息窗口。我只是不知道该怎么做。似乎我会有一个 if 语句来检查 URL 参数“window”是否等于“oregoncaves”,然后为该标记打开该信息窗口。再次感谢您的帮助。

小号

4

1 回答 1

0

您的问题提到了缩放和中心的 url 参数,但我已经检查了您链接中的页面,它使用标准的 JavaScript v3 API 来处理这些,而不是 url 参数。

这似乎有点令人困惑,所以我可能遗漏了一些东西,但如果你想创建一个立即打开的InfoWindow开发指南,只需创建InfoWindowapi-doc将与之关联的对象(通常是google.maps.Markerapi-doc),然后创建 InfoWindow在地图创建之后(代码主要取自开发者指南,带有一些小模组):

var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
var myOptions = {
  zoom: 4,
  center: myLatlng,
  mapTypeId: google.maps.MapTypeId.ROADMAP
}

var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

var contentString = '<div id="content">'+
    '<div id="siteNotice">'+
    '</div>'+
    '<h2 id="firstHeading" class="firstHeading">Uluru</h2>'+
    '<div id="bodyContent">'+
    '<p><b>Uluru</b>, also referred to as <b>Ayers Rock</b>, is a large ' +
    'sandstone rock formation in the southern part of the '+
    'Northern Territory, central Australia. It lies 335 km (208 mi) '+
    'south west of the nearest large town, Alice Springs; 450 km '+
    '(280 mi) by road. Kata Tjuta and Uluru are the two major '+
    'features of the Uluru - Kata Tjuta National Park. Uluru is '+
    'sacred to the Pitjantjatjara and Yankunytjatjara, the '+
    'Aboriginal people of the area. It has many springs, waterholes, '+
    'rock caves and ancient paintings. Uluru is listed as a World '+
    'Heritage Site.</p>'+
    '<p>Attribution: Uluru, <a href="http://en.wikipedia.org/w/index.php?title=Uluru&oldid=297882194">'+
    'http://en.wikipedia.org/w/index.php?title=Uluru</a> (last visited June 22, 2009).</p>'+
    '</div>'+
    '</div>';

var marker = new google.maps.Marker({
    position: myLatlng,
    map: map,
    title:"Uluru (Ayers Rock)"
});

var infowindow = new google.maps.InfoWindow({
    content: contentString
});
infowindow.open(map,marker);
于 2012-06-27T03:36:15.690 回答