php – 将拖拽的路线数据从Google地图中删除
|
我正在开展一个项目,而且我无法继续前进,需要一些认真的帮助.我来给你一些背景知识.
我正在开发一项服务,让用户骑自行车去 http://ridestreaming.com/google_maps/ 在我无法通行的墙上,是如何获得用户编辑的 http://ridestreaming.com/google_maps/workflow.js var newString = JSON.stringify(directions);
//set up area to place drop directionsResponse object string
var directions_response_panel = document.getElementById("directions_response");
//dump any contents in directions_response_panel
directions_response_panel.innerHTML = "";
//add JSON string to it
directions_response_panel.innerHTML = "<pre>" + newString + "</pre>";
//run the ajax
runAjax(directions);
我们可以将路由数据作为JSON文件,字符串化并发送 这个人有没有机会帮忙解决这个问题?我正把头靠在墙上.任何回应都非常感谢.谢谢你的时间!
我一直在做类似的事情,发现这真的很难,但经过几个小时的努力,我设法从User-Dragged路线获取所有航路点并将其保存到数据库中.
所以,我有一个字段,用于以“;”分隔所有路点. 你必须有这个: directionsDisplay = new google.maps.DirectionsRenderer({
'map': map,'preserveViewport': true,'draggable': true
});
在你的初始化功能 这是我的JS的一部分: var currentDirections;
var directionsDisplay;
var waypoints = [];
function saveWaypoints()
{
waypoints = [];
var waypts_field = document.getElementById('waypoints').value.split(';');
for(var bo = 0; bo < waypts_field.length; bo++)
{
if(waypts_field[bo] == ' ' || waypts_field[bo] == '')
{
waypts_field.splice(bo,1);
bo -= 1;
continue;
}
waypoints.push({ location: waypts_field[bo],stopover: false });
}
}
function getWaypoints()
{
currentDirections = directionsDisplay.getDirections();
var route = currentDirections.routes[0];
totalLegs = route.legs.length;
for (var i = 0; i < route.legs.length; i++) {
var routeSegment = i+1;
if(route.legs[i].via_waypoint[0] === undefined) continue;
document.getElementById('waypoints').value = '';
var via_waypoint_count = route.legs[i].via_waypoint.length;
queue = 0;
for(var bi = 0; bi < via_waypoint_count; bi++)
{
var count = 0;
var lat;
var lng;
for (key in route.legs[i].via_waypoint[bi]['location'])
{
if(count > 1) break;
if(count == 0)
{
lat = route.legs[i].via_waypoint[bi]['location'][key];
count++;
continue;
}
lng = route.legs[i].via_waypoint[bi]['location'][key];
count++;
}
reverseGeoCode(new google.maps.LatLng(lat,lng));
}
}
}
function reverseGeoCode(latlng)
{
queue += 60;
setTimeout(function(){
geocoder.geocode({ 'latLng': latlng },function(results,status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
document.getElementById('waypoints').value += results[1].formatted_address + '; ';
}
} else {
alert("Geocoder failed due to: " + status);
}
});
},queue * 10);
}
我很快把它从我的JS中删除了,所以如果它没有意义,我会发布我的所有JS并一点一点解释它.. 谢谢 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
