2013-07-23 183 views
3

我正在使用DirectionRenderer(gmap3)來顯示用戶指示。問題是它顯示匹配,即使它找不到完全匹配。例如:SomeFakePlace,myRealCity將匹配myRealCity,即使它不能匹配SomeFakePlace。Google maps direction renderer only only

因此它顯示了從市中心到該地點的路線。目的地是固定的(myLatLng)

我希望它返回null,並且如果找不到一個路由則不顯示路由。我有體面的錯誤顯示來處理。

$("#map-canvas-single").gmap3({ 
      getroute:{ 
      options:{ 
       origin:$("#directions-from").val(), 
       destination:myLatlng, 
       travelMode: google.maps.DirectionsTravelMode.DRIVING 
      }, 
      callback: function(results){ 
       console.log(results); 
        var point= results.routes[0].overview_path[0] 
        window.directionMarker = new google.maps.Marker({ 
         position: new google.maps.LatLng(point.jb,point.kb), 
         title:$("#directions-from").val(), 
         //icon:"http://maps.google.com/mapfiles/ms/icons/<?php if($this->listing->type=="pg"):?>green<?php else: ?>purple<?php endif;?>-dot.png" 

        }); 
        window.directionMarker.setMap($(this).gmap3("get")); 

      if(!results) 
       noty({text:"Place not found!",type:"error"}); 
      else 
      { 
       $(this).gmap3({ 
        directionsrenderer:{ 
         container: $("#directions-container"), 
          id:"directions", 
         options:{ 
         directions:results, 
         suppressMarkers :true //<<Look here>> 
         } 
        } 
        }); 

      } 
      } 
     } 
     }); 

該代碼工作正常,所有。我認爲這是方向渲染器服務的錯,而不是gmaps。我確定htere必須是完全匹配的參數

+0

沒有任何辦法。 :( –

回答