Google maps api 3 谷歌地图方向渲染器仅精确匹配
我正在使用DirectionRenderer(gmap3)显示用户方向。问题是,即使找不到精确的匹配项,它也会显示匹配项。我的真实城市将与我的真实城市相匹配,即使它不能与某个虚假的地方相匹配 所以它显示了从城市中心到这个地方的方向。目标已固定(myLatLng) 我希望它返回null,如果找不到路由,则不显示路由。我有很好的错误显示来处理这个问题Google maps api 3 谷歌地图方向渲染器仅精确匹配,google-maps-api-3,jquery-gmap3,Google Maps Api 3,Jquery Gmap3,我正在使用DirectionRenderer(gmap3)显示用户方向。问题是,即使找不到精确的匹配项,它也会显示匹配项。我的真实城市将与我的真实城市相匹配,即使它不能与某个虚假的地方相匹配 所以它显示了从城市中心到这个地方的方向。目标已固定(myLatLng) 我希望它返回null,如果找不到路由,则不显示路由。我有很好的错误显示来处理这个问题 $("#map-canvas-single").gmap3({ getroute:{ options
$("#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>>
}
}
});
}
}
}
});
$(“#地图画布单”).gmap3({
获取路线:{
选项:{
原点:$(“#方向自”).val(),
目的地:myLatlng,
travelMode:google.maps.Directions travelMode.DRIVING
},
回调:函数(结果){
控制台日志(结果);
var point=results.routes[0]。概述\u路径[0]
window.directionMarker=新建google.maps.Marker({
位置:新的google.maps.LatLng(point.jb,point.kb),
标题:$(“#方向”).val(),
//图标:“http://maps.google.com/mapfiles/ms/icons/greenpurple-dot.png"
});
window.directionMarker.setMap($(this.gmap3(“get”);
如果(!结果)
noty({text:“未找到位置!”,键入:“error”});
其他的
{
$(本文件)。gmap3({
方向渲染器:{
容器:$(“#方向容器”),
id:“方向”,
选项:{
方向:结果,
真的吗//
}
}
});
}
}
}
});
代码运行良好。我认为这是方向渲染器服务的错,而不是GMAP的错。我确信一定有一些参数可以精确匹配,我不熟悉谷歌地图API,但我要做的是在源地址上查找地理代码并找到lat,lng。您通常会获得具有置信度级别的坐标,因此您可以有一个最小阈值,在该阈值之下抛出错误 还有,别忘了mapquest
没有任何办法:(