我已经尝试过这种方法来获取海拔高度,使用经度和纬度
private double lookingForAltitude(double latitude, double longitude) {
double result = Double.NaN;
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
String url = "http://maps.googleapis.com/maps/api/elevation/"
+ "xml?locations=" + String.valueOf(longitude)
+ "," + String.valueOf(latitude)
+ "&sensor=true";
HttpGet httpGet = new HttpGet(url);
try {
HttpResponse response = httpClient.execute(httpGet, localContext);
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream instream = entity.getContent();
int r = -1;
while ((r = instream.read()) != -1)
respStr.append((char) r);
String tagOpen = "<elevation>";
String tagClose = "</elevation>";
if (respStr.indexOf(tagOpen) != -1) {
int start = respStr.indexOf(tagOpen) + tagOpen.length();
int end = respStr.indexOf(tagClose);
String value = respStr.substring(start, end);
result = (double)(Double.parseDouble(value));
}
instream.close();
}
} catch (ClientProtocolException e) {}
catch (IOException e) {}
return result;
}
不幸的是不起作用
以通过为例
double latitude = 48.856908
double longitude = 2.352426
法国巴黎蒂沃利街
得到-3997.6191406
怎么了??
我在其他地方也得到了错误的价值。
附言
我听说这个功能的请求限制是2500。这个是和每个IP有关还是所有使用我的证书的应用程序的最大数量?