将源和目标之间的所有位置存储在表(数据库)中

时间:2012-08-23 12:51:22

标签: google-app-engine google-maps-api-3

我想从google地图解析源和目标之间的所有位置,如下所示:                            Google Maps API v3说明示例                                          

 <script type="text/javascript"> 

 var directionsService = new google.maps.DirectionsService();
 var directionsDisplay = new google.maps.DirectionsRenderer();

 var map = new google.maps.Map(document.getElementById('map'), {
   zoom:7,
   mapTypeId: google.maps.MapTypeId.ROADMAP
 });

 directionsDisplay.setMap(map);
 directionsDisplay.setPanel(document.getElementById('panel'));

 var request = {
   origin: 'Kolkata', 
   destination: 'Patna',
   travelMode: google.maps.DirectionsTravelMode.DRIVING
 };

//echo 'directionsService.route()';

 directionsService.route(request, function(response, status) {
   if (status == google.maps.DirectionsStatus.OK) {
     directionsDisplay.setDirections(response);
   }
 });
</script> 
</body> 
</html>

我想要http://maps.googleapis.com/maps/api/directions/xml?origin=%22+kolkata+%22&destination=%22+patna+%22&sensor=false

之类的东西

这样我就可以解析位置并存储在我的数据库中的表中。请帮忙找到一种方法来做到这一点。谢谢你提前

1 个答案:

答案 0 :(得分:0)

我认为您需要(使用您正在使用的语言)将XML转换为数组或数据表(或等效的),然后将这些行逐行插入数据库。

PHP:http://gaarf.info/2009/08/13/xml-string-to-php-array/

VB.NET:http://msdn.microsoft.com/en-us/library/ekw4dh3f(v=vs.71).aspx