2012-07-16 40 views
9

Tôi đang sử dụng dịch vụ này https://developers.google.com/maps/documentation/javascript/directions để tạo tuyến đường giữa hai điểm đánh dấu.Ẩn điểm đánh dấu khỏi dịch vụ chỉ đường trong bản đồ google api v3

Vấn đề là khi tôi chạy hàm để tạo đường dẫn, anh ấy nhập cho tôi hai điểm đánh dấu theo mặc định từ bản đồ google (đầu và cuối) khi tôi đã tạo các điểm đánh dấu với kiểu khác nhau.

Kết quả: tại mỗi điểm có điểm đánh dấu của tôi và bản đồ google mặc định của trình đánh dấu ở trên.

Làm cách nào để ẩn điểm đánh dấu được tạo bởi google?

Mã Tôi đang sử dụng là:

function makePathToMarker(position1, position2) { 
    var request = { 
     origin: new google.maps.LatLng(myLocation.split(",")[0],myLocation.split(",")[1]), 
     destination: new google.maps.LatLng(position1, position2), 
     travelMode: google.maps.DirectionsTravelMode.DRIVING 
    }; 

    var directionsService = new google.maps.DirectionsService(); 

    directionsService.route(request, function(response, status) { 
     if (status == google.maps.DirectionsStatus.OK) { 
      directionsDisplay.setDirections(response); 
     } 
    }); 
} 

Trả lời

30

Khi instatiating các DirectionsRenderer, thiết suppressMarkers là true.

directionsDisplay = new google.maps.DirectionsRenderer(
    { 
     suppressMarkers: true 
    }); 

Đây là reference

+0

Cảm ơn bạn rất nhiều! –

+0

tôi có thể thêm cái này ở đâu –

Các vấn đề liên quan