私のGoogleマップは、方向サービスによって与えられ、方向レンダラー(ここではDirectionsDisplayと呼ばれます)によってレンダリングされたルートを中心としています。Googleマップの経路ではなく、インフォウインドウのセンターマップ
私が読んだドキュメントや多数のスレッドやフォーラムによると、InfoWindowはバージョン3.0(これは私が使用している)を中心にautoPanする必要があります。
すべてのコールバックが呼び出されるまで待っていますが、gmapsのtileloadedイベントが発生したときにウィンドウを開こうとしました。アイドルイベントも発生しました。
何かに関係なく、地図は常にルートの周りに集中します(したがって、インフォウィンドウをビューポートから押し出す)。
私はここで間違っていますか?
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);
}
});
ここで何か間違いはありません。あなたがデモをプレイすると助けになるかもしれません。 http://jsfiddle.net – Gareth