Я хотел бы нарисовать маршрут между двумя маркерами, которые определены в этом файле geoJSON:
{
"type": "FeatureCollection",
"features":
[
{ "type": "Feature",
"geometry": {"type": "Point", "coordinates": [-73.563032, 45.495403]},
"properties": {"prop0": "value0"}
},
{ "type": "Feature",
"geometry": {"type": "Point", "coordinates": [-73.549762, 45.559673]},
"properties": {"prop0": "value0"}
}
]
}
Два маркера хорошо отображаются на карте.
Теперь я хочу создать маршрут (автомобиль) между этими двумя точками.
У меня есть эта функция javascript, которая позволяет мне рисовать маршрут из формы, заполненной пользователем:
function calculate() {
origin = document.getElementById('origin').value;
destination = document.getElementById('destination').value;
var request = {
origin: origin,
destination: destination,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
}
А теперь я хотел бы заменить «источник» и «пункт назначения» двумя точками, определенными в моем файле geoJSON, чтобы создать маршрут между этими двумя точками.
Есть идеи ?
Спасибо за помощь !