私のグーグルマップは、方向サービスによって与えられ、方向レンダラー(ここではdirectionDisplayと呼ばれる)によってレンダリングされるルートを中心にしています。
私が読んだドキュメントと多くのスレッドとフォーラムによると、infoWindow はバージョン 3.0 (私が使用している) を中心に自動パンする必要があります。
すべてのコールバックが呼び出されるまで待っています。gmaps tileloaded-Event と idle イベントが発生したときにウィンドウを開こうとしました。
何があっても: マップは常にルートを中心に表示されます (したがって、情報ウィンドウがビューポートの外に押し出されます)。
ここで何が間違っていますか?
directionsService.route(request, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(result);
directionsDisplay.suppressMarkers = true;
if(this.marker){
this.marker.setPosition(result.routes[0].overview_path[result.routes[0].overview_path.length-1]);
} else{
this.marker = new google.maps.Marker({
position: result.routes[0].overview_path[result.routes[0].overview_path.length-1],
map: Gmap.map
});
}
var contentString = '<div id="infowindow_title">Hello World</div><div id="infowindow_cat">Lorem Ipsum</div>';
if(!this.infoWindow){
this.infoWindow = new google.maps.InfoWindow({
content: contentString
});
} else {
this.infowindow.setContent(contentString);
}
this.infoWindow.open(Gmap.map, this.marker);
}
});