다른 색상으로 렌더링하려고하는 방향 설정이 있습니다. 구글의 지시를 요청하지만 상태를 저장하는 방법을 모르므로 라우팅 결과가 반환되면 각각을 적절한 색으로 렌더링 할 수 있습니다.상태를 자바 스크립트의 하위 함수로 전달 하시겠습니까?
그래서, 예를 들어, 나는이 목적을 가지고 : 나는 for 루프에서 (예를 들어, 인덱스 상태를 연결할 수있는 방법
directionsService = new google.maps.DirectionsService();
for(var i = 0; i < routes.length; i++){
var dir_request = {
origin : new google.maps.LatLng(routes[i]['start_lat'], routes[i]['stop_lng']),
destination : new google.maps.LatLng(routes[i]['end_lat'], routes[i]['end_lng']),
travelMode : google.maps.TravelMode.WALKING
};
directionsService.route(dir_request, function(result, status) {
if(status == google.maps.DirectionsStatus.OK){
// render with custom logic depending on which route this is here
}
})
}
: 여기
{routes: [{start_lat : 0.0, start_lng : 0.0, end_lat : 1.0, end_lng : 1.0, color : "#ff0000"},
{start_lat : 1.0, start_lng : 1.0, end_lat : 2.0, end_lng : 2.0, color : "#00ff00"}]}
내 기능입니다)를 각 요청에 추가하여 결과 처리 함수에서 액세스 할 수 있도록 하시겠습니까?
이 호출 폐쇄, 나는 – Markasoftware