使用Long/Lat与谷歌地图API的方向准确性
Accuracy of directions using Long/Lat with Google Maps API
我使用Google Maps API v3来显示从用户定义的起点到我的属性的方向。
除了结束点的准确性之外,这在技术上是可以工作的。我已经把我的房子的Long/Lat定义到确切的点,但方向仍然把你带到大约100米外的一条街上。
是否有一种方法可以迫使方向带你到一个精确的点?
这是我的代码,如果它有帮助…
function getDirections(x, y) {
$("#directionsPanel").html("");
var directionsService = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer();
var myOptions = {
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP,
scrollwheel: false
}
var map = new google.maps.Map(document.getElementById("map"), myOptions);
directionsDisplay.setPanel(document.getElementById('directionsPanel'));
directionsDisplay.setMap(map);
var request = {
origin: x,
destination: $('.lat').text() + ',' + $('.lng').text() ,
travelMode: google.maps.DirectionsTravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.IMPERIAL,
provideRouteAlternatives: true,
region: "GB"
};
directionsService.route(request, function (response, status) {
directionsDisplay.setDirections(response);
$(".noValidRoute").hide();
});
}
假设getDirections(x, y)
中的x,y
是您的属性的坐标,您只使用x
。
试
;function getDirections(x, y) {
var origin = new google.maps.LatLng(x,y)
$("#directionsPanel").html("");
var directionsService = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer();
var myOptions = {
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP,
scrollwheel: false
}
var map = new google.maps.Map(document.getElementById("map"), myOptions);
directionsDisplay.setPanel(document.getElementById('directionsPanel'));
directionsDisplay.setMap(map);
var request = {
origin: origin,
destination: $('.lat').text() + ',' + $('.lng').text() ,
travelMode: google.maps.DirectionsTravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.IMPERIAL,
provideRouteAlternatives: true,
region: "GB"
};
directionsService.route(request, function (response, status) {
directionsDisplay.setDirections(response);
$(".noValidRoute").hide();
});
}
有一个可以传递的"radius"变量。不知道如何在JS中做,但与web-api看看这个:
http://cbk0.google.com/cbk?output=xml&你= 43.19199、-5.4288,半径= 500
它什么也不返回
将半径更改为5000,您将得到一个结果。如果不行,试试更高的变焦级别?
相关文章:
- 使用谷歌地图API和phonegap显示当前位置+方向
- 基于谷歌地图API方向服务构建的替代路线
- 谷歌地图API-从方向的原点检索定位
- 谷歌地图 API 方向
- 如何使用谷歌地图 API v3 旋转地图方向
- 使用 Web 音频 API 设置侦听器方向
- 谷歌地理定位和方向API
- MapQuest JS API-通过密切关注点列表来获取方向
- 映射API自定义可拖动方向
- 使用谷歌地图api获取方向,无需使用地图
- JSONP和谷歌地图方向API
- 如何使用谷歌地图API显示静态方向
- 我可以从网页(而不是服务器)调用谷歌地图方向API吗
- 带有方向箭头的地理位置 api
- 谷歌地图API方向 - 在2个不同的侧边栏之间切换
- 谷歌地图API方向上的时间相关信息
- 谷歌地图API:方向结果没有显示
- 谷歌地图Api -方向服务不工作的一些原点和目的地
- google映射api方向javascript变量
- 谷歌地图API方向服务在纬度和经度和地理位置标记之间