/**
* @author 距离计算
*
*/
public class DistanceUtil {
private static final String showLocationUrl = "http://api.map.baidu.com/geocoder/v2/?output=json&ak=RguGdBfvanKG10lrLHtUAtka&address=";
private static final String waypointsDistanceUrl = "http://api.map.baidu.com/telematics/v3/distance?output=json&ak=RguGdBfvanKG10lrLHtUAtka&waypoints=";
@SuppressWarnings("unchecked")
public static Double twoCitysDistance(String startCityName, String endCityName){
Double distance = 0.00;
Map<String, Object> startShowLocation = JsoupTool.getJson(showLocationUrl+startCityName, null);
Map<String, Object> startResultLocation = (Map<String, Object>) startShowLocation.get("result");
Map<String, Object> startLocation = (Map<String, Object>) startResultLocation.get("location");
String startLng = startLocation.get("lng").toString();
String startLat = startLocation.get("lat").toString();
Map<String, O
用百度地图api计算两个地方的距离
最新推荐文章于 2025-09-22 13:29:39 发布
该博客展示了如何利用百度地图API获取地理位置坐标,并计算两个城市之间的距离。通过发送HTTP请求获取JSON数据,解析得到经纬度,进一步调用距离计算接口获取精确距离。

最低0.47元/天 解锁文章
2641





