gpt4 book ai didi

google-maps - 谷歌地图如何在最近的道路上强制标记

转载 作者:行者123 更新时间:2023-12-05 07:59:06 25 4
gpt4 key购买 nike

我正在做一个车辆跟踪项目,我正在从数据库中获取坐标,并显示在谷歌地图上。这是我的代码......!!

function get_coordinates(checkbox){
var v_id=checkbox.id;
if(checkbox.checked){
var hr = new XMLHttpRequest();
hr.open("POST", "fetch_coordinates.php", true);
hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
hr.onreadystatechange = function() {
if(hr.readyState == 4 && hr.status == 200) {
var data = JSON.parse(hr.responseText);
var lat=data.loc.lat;
var lon=data.loc.lon;
addmarker(lat,lon,v_id);
}
}
hr.send("id="+v_id);
} else{
var mark = markers[v_id]; // find the marker by given id
mark.setMap(null);
delete markers[v_id];

}
}
function addmarker(lat,lon,v_id){
var marker = new google.maps.Marker({
id: v_id,
position: new google.maps.LatLng(lat, lon),
zoom: 8,
map: map,
title: 'Vehicle No: '+v_id,
icon: 'live.gif',
optimized:false

});
markers[v_id] = marker;
bounds.extend(new google.maps.LatLng(lat,lon));
// map.setOptions({center:new google.maps.LatLng(lat,lon),zoom:8});
map.fitBounds(bounds);
}

但问题是,有时我会得到距离道路 1.2 英寸的 GPS 坐标(可能是因为设备精度较低或信号失真等)我应该如何强制我的标记在路上自动调整?有什么办法,使用方向渲染或任何其他提示???请帮忙

最佳答案

在 2017 年,正确的做法是 Roads API Snap to Roads 服务。

您可以阅读有关此网络服务的信息

https://developers.google.com/maps/documentation/roads/snap

The Google Maps Roads API takes up to 100 GPS points collected along a route, and returns a similar set of data, with the points snapped to the most likely roads the vehicle was traveling along. Optionally, you can request that the points be interpolated, resulting in a path that smoothly follows the geometry of the road.

关于google-maps - 谷歌地图如何在最近的道路上强制标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22880381/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com