DirectionsService를 사용할 때 directionsoverendr에 mouseover 이벤트 리스너를 추가하려면 어떻게해야하나요?directionsRenderer에 mouseover 이벤트 추가 Google Maps API v3
리스너를 직선에 추가하는 방법을 알고 있지만 directionsRenderer에서 객체를 찾지 못하는 것 같습니다.
function getStraightLine(coordinates) {
if (progress.length == 0)
progress = coordinates;
else
progress.push(coordinates[1]);
updateDistance();
var line = new google.maps.Polyline({
path: coordinates,
strokeColor: "#FF0000",
strokeOpacity: .5,
strokeWeight: 2,
map: map
});
google.maps.event.addListener(line, 'mouseover', function(){
alert("moused over straight line!");
});
return line;
}
을하지만 그렇지 않은 :
예를 들어이 작품
대신 directionsPath 내가 시도한 결과function getDirectionsPath(coordinates) {
var directionsPath = new google.maps.DirectionsRenderer();
directionsPath.setMap(map);
var request = {
origin: coordinates[0],
destination: coordinates[1],
travelMode: google.maps.TravelMode.WALKING
};
directionsService.route(request, function (result, status) {
if (status == google.maps.DirectionsStatus.OK) {
var coordinates = result.routes[0].overview_path;
if (progress.length == 0)
progress = coordinates;
else
progress = progress.concat(coordinates);
directionsPath.setDirections(result);
google.maps.event.addListener(directionsPath, 'mouseover', function(){
alert("moused over straight line!");
});
}
});
return directionsPath;
}
, result.routes [0], 그리고 몇 가지 다른.
그래서 어떤 물건을 사용해야합니까?
나는 이것을 답으로 표시하고 있지만 끌기 이벤트를 사용하는 것처럼 여전히 완벽하지는 않습니다. –