0
我的谷歌地圖圍繞着一個路線,由一個方向服務給出並由一個方向渲染器渲染(這裏稱爲directionsDisplay)。infowindow的中心地圖,而不是谷歌地圖的路線
根據我讀過的文檔和許多主題和論壇,infoWindow應該autoPan以3.0版本(我正在使用)爲中心。
我在等待直到所有回調被調用,我試圖打開窗口,當gmaps tileloaded-Event被觸發,以及空閒事件。
無論如何:地圖總是圍繞着路線(因此會將視線從視口中推出)。
我在這裏做錯了什麼?
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 2012-04-20 00:38:39