0
map.fitboundsの使用中に少し問題が発生しました。私はマップ上に2つのポイントを渡しており、これに沿って方向サービスを使用しています。私は2つの与えられた点間のマップを中央にmap.fitboundsを使用していますが、マップが実際にこの特定のコードの一部のための世界観を示す終わる問題に遭遇していますGoogle Maps API v3 JS map.fitbounds
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
window.addEvent('domready', function() {
initialize();
});
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var currentDirections = null;
var clat = 52.03574;
var clng = 0.58363;
var dlat = 51.08577;
var dlng = -1.31712;
function initialize()
{
var mOptions = {
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map($("mapCanvas"), mOptions);
directionsDisplay = new google.maps.DirectionsRenderer({
'map': map,
'preserveViewport': true,
'draggable': true//,
//'suppressMarkers': true
});
directionsDisplay.setPanel($("directions_panel"));
google.maps.event.addListener(directionsDisplay, 'directions_changed', function() {
currentDirections = directionsDisplay.getDirections();
});
var start = 'Little Yeldham, Halstead, Essex CO9 4JZ, UK';
var end = 'Winchester, Hampshire SO21, UK';
var request = {
origin: start,
destination: end,
travelMode: google.maps.DirectionsTravelMode.DRIVING,
unitSystem: google.maps.DirectionsUnitSystem.IMPERIAL
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setMap(map);
directionsDisplay.setDirections(response);
}
});
var collectionPoint = new google.maps.LatLng(clat, clng);
var deliveryPoint = new google.maps.LatLng(dlat, dlng);
var bounds = new google.maps.LatLngBounds(collectionPoint, deliveryPoint);
map.fitBounds(bounds);
}
</script>
できるすべてのヘルプやポイント適切な表示距離を表示するにはどうすればいいですか?