高德地图WebAPI : 驾车路径规划
来源:互联网 发布:网络品牌营销案例分析 编辑:程序博客网 时间:2024/04/28 14:51
参考API
一个demo
获取路径规划返回结果中的两点间最短驾车距离
import java.io.BufferedReader;import java.io.BufferedReader;import java.io.InputStreamReader;import java.net.URI;import java.net.URL;import java.net.URLConnection;import net.sf.json.JSONArray;import net.sf.json.JSONObject;public class Test2 { public static String getHttpResponse(String allConfigUrl) { BufferedReader in = null; StringBuffer result = null; try { //url请求中如果有中文,要在接收方用相应字符转码 URI uri = new URI(allConfigUrl); URL url = uri.toURL(); URLConnection connection = url.openConnection(); connection.setRequestProperty("Content-type", "text/html"); connection.setRequestProperty("Accept-Charset", "utf-8"); connection.setRequestProperty("contentType", "utf-8"); connection.connect(); result = new StringBuffer(); //读取URL的响应 in = new BufferedReader(new InputStreamReader(connection.getInputStream(),"utf-8")); String line; while ((line = in.readLine()) != null) { result.append(line); } return result.toString(); } catch (Exception e) { e.printStackTrace(); }finally { try { if (in != null) { in.close(); } } catch (Exception e2) { e2.printStackTrace(); } } return null; } /* * 高德地图WebAPI : 驾车路径规划 */ public static String distance(String origins,String destination) { int strategy = 2;//strategy=2距离优先,一共有九种查询模式,详情查看API String url = "http://restapi.amap.com/v3/direction/driving?" + "origin="+origins +"&destination="+destination +"&strategy="+strategy +"&extensions=base&key=你申请的key"; JSONObject jsonobject = JSONObject.fromObject(getHttpResponse(url)); System.out.println(jsonobject.toString()); JSONArray pathArray = jsonobject.getJSONObject("route").getJSONArray("paths"); String distanceString = pathArray.getJSONObject(0).getString("distance"); return distanceString; } public static void main(String[] args) { //格式: 经度,纬度 //注意:高德最多取小数点后六位 String origin = "116.398140"+","+"26.059369"; String destination = "116.374028"+","+"39.907586"; String distance = distance(origin, destination); System.out.println(distance); }}
0 1
- 高德地图WebAPI : 驾车路径规划
- 高德地图JavascriptAPI:驾车路径规划
- 高德地图驾车路径规划详情获取
- Android 高德地图驾车路线规划
- android 高德地图 驾车路线规划
- 高德地图路径规划
- 高德地图中实现实时定位、驾车路线规划,点间距
- 高德地图线路规划的接入使用(步行-公交-驾车)
- 高德地图04--路径规划
- Android 基于高德地图路径规划
- 【高德地图API】从零开始学高德JS API(五)路线规划——驾车|公交|步行
- 【高德地图API】从零开始学高德JS API(五)路线规划——驾车|公交|步行
- 高德地图WebAPI:行驶距离测量
- 高德地图---路径规划---语音导航的开发
- iOS高德地图使用-搜索,路径规划
- iOS高德地图使用-搜索,路径规划
- 高德地图简单实现及路径规划
- Android百度地图——路径规划(驾车、步行和公交线路搜索)
- 控制浏览器窗口的可以缩放的最小高度和宽度
- 【HNOI2012】bzoj2730 矿场搭建 【解法二】
- maven实战
- 使用反射读取enum的属性
- 超自然的箭头函数学习初步
- 高德地图WebAPI : 驾车路径规划
- redis集群搭建
- scikit-learn主要模块和基本使用方法
- 设计模式3
- [CodeForces - 140C New Year Snowmen] 贪心 + STL 优先队列
- opencv学习(9)漫水填充、图像金字塔、阈值化的介绍
- 经典语录
- 转载】Unity3D美术方面贴图蓄力帖(值得珍藏学习)
- 动态规划(acm hdu 5791) 求公共子序列