2

都市の天気情報ウィンドウを開くために、Googleマップインスタンスの天気レイヤーをクリックをトリガーしようとしています。

//Create the map
var options = {
  center: new google.maps.LatLng(49.265984,-123.127491),
};
var map = new google.maps.Map(document.getElementById("map_canvas"), options);

//Create the weather layer
var weatherLayer = new google.maps.weather.WeatherLayer();
weatherLayer.setMap(map);

//Create the event, how?
var event = ?;

//Trigger the click
google.maps.event.trigger(weatherLayer, 'click', event);

問題は、トリガー関数に渡さなければならないイベントです。WeatherMouseEventのインスタンスである必要があります。このインスタンスは、ユーザーがマーカーの1つをクリックしたときにレイヤーによって作成されますが、このイベントを生成する方法がわかりません。

ありがとう!

4

2 に答える 2

1

これを試して:

var infoWindow = new google.maps.InfoWindow();

var wEvent = google.maps.event.addListener(weatherLayer, 'click', myWeatherClick);

function myWeatherClick(wme) {
    infoWindow.setPosition(wme.latLng);
    infoWindow.setContent(wme.infoWindowHtml);
    infoWindow.open(map);
}

イベントをトリガーします。

var wme = {
        latLng: map.getCenter(),
        infoWindowHtml:'I\'ve been clicked'
    }
    google.maps.event.trigger(weatherLayer, 'click', wme);
于 2012-07-07T06:22:23.597 に答える
1

現在はできません。Googleの従業員から返信がありました:

残念ながら、プログラムで天気レイヤー情報ウィンドウを開くことはできません。APIでこれを確認したい場合は、機能リクエストを提出してください:http ://code.google.com/p/gmaps-api-issues/issues/list

エノック

機能リクエストを作成しました。

于 2012-07-07T11:08:09.203 に答える