我已经在谷歌地图中绘制了一条折线,但是当试图在单个地图中绘制两条线时它失败了......它在谷歌地图上没有显示任何内容
谁能告诉我一些解决方案
见-http: //jsfiddle.net/wLeBh/12/
我的 javascript 如下所示
function initMap()
{
alert("entered!!!");
var routes = [{origin:'p t usha road, kozhikode',
destination:'cooperative hospital, eranjipalam, kozhikode'
},
{origin:'IIM, Kozhikode',
destination:'VELLIMADUKUNNU, KOZHIKODE'
}
];
try{
var rendererOptions = {
preserveViewport: true,
suppressMarkers:true,
routeIndex:1
};
var directionsService = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer();
//routes.each(function(route){
for (var i = 0, l = routes.length; i < l; i++) {
var obj = routes[i];
alert(obj.origin);
var request = {
origin: obj.origin,
destination: obj.destination,
travelMode: google.maps.TravelMode.DRIVING
};
map = new google.maps.Map(document.getElementById("map"), {
center: new google.maps.LatLng(0,0),
zoom: 10,
maxZoom:16,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControlOptions:
{
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
},
navigationControl: true,
navigationControlOptions:
{
style: google.maps.NavigationControlStyle.SMALL
}
});
var directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);
directionsDisplay.setMap(map);
directionsService.route(request, function(result, status) {
console.log(result);
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(result);
}
});
}
}catch(e){alert(e);}
}