Google maps api 3 google.maps.DirectionsRenderer:如何在一张地图中渲染所有停止点
嗨,我有一张显示航天飞机方向的地图,下面是地图和方向初始化代码Google maps api 3 google.maps.DirectionsRenderer:如何在一张地图中渲染所有停止点,google-maps-api-3,Google Maps Api 3,嗨,我有一张显示航天飞机方向的地图,下面是地图和方向初始化代码 var centerLatlng = new google.maps.LatLng(-34.942799,138.553365); var myOptions = { zoom: 13, center: centerLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP, zoomControl: true, zoomControlOptions: {
var centerLatlng = new google.maps.LatLng(-34.942799,138.553365);
var myOptions = {
zoom: 13,
center: centerLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
zoomControl: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.LARGE
},
panControl:true,
streetViewControl: false,
OverviewMapControlOptions:
{
opened: true
}
};
var map = new google.maps.Map(document.getElementById("map-guide-google-map"), myOptions);
以下是显示方向
function DisplayDirection(directionList){
var directionsService = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer({
markerOptions: {
visible:false
}
});
directionsDisplay.setMap(map);
//Request 0
var increaseSize = 7;
var index =0;
var theoryCurrentEndIndex = index + increaseSize;
var maxmimumIndex = directionList.length-1;
var origin = directionList[index];
var destination = theoryCurrentEndIndex < maxmimumIndex?directionList[theoryCurrentEndIndex]:directionList[maxmimumIndex];
var actualCurrentEndIndex = theoryCurrentEndIndex < maxmimumIndex?theoryCurrentEndIndex: maxmimumIndex;
var waypoints = new Array();
if(actualCurrentEndIndex-index>1) {
for(var i=index+1;i<actualCurrentEndIndex;i++) {
waypoints.push(
{
location:directionList[i],
stopover:true}
);
}
}
var request = {
origin: origin,
destination: destination,
waypoints : waypoints,
provideRouteAlternatives:false,
travelMode: google.maps.TravelMode.WALKING,
unitSystem: google.maps.UnitSystem.METRIC
}
directionsService.route(request, function(result, status) {
if(status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(result);
}
}) ;
}
函数显示方向(方向列表){
var directionsService=new google.maps.directionsService();
var directionsDisplay=新建google.maps.DirectionsRenderer({
标记选项:{
可见:假
}
});
方向显示.setMap(地图);
//请求0
var increaseSize=7;
var指数=0;
var Theory CurrentedIndex=指数+增量大小;
var maxmimumIndex=directionList.length-1;
变量来源=方向列表[索引];
var destination=TheoryCurrentIndex1){
对于(var i=index+1;iI)在您的代码中没有看到任何LatLongBounds对象。您想“重置”什么?我没有使用LatLongBounds,因为它似乎不起作用。我所要做的就是让所有的停止点出现在一个地图屏幕中