有人用过 map.google.com 吗?

wugamp 2017-02-03 02:34:45
在编程序,根据基站定位。
目前已经能正确获得基站的信息,如下:MCC: 460 mnc: 0 lac: 43042 cid: 26360769
但是用它向 google 查询经纬度的时候出错了,错误信息 e.Message 为 null。
会不会是因为 maps.google.com 被封掉的缘故啊?我用PC ping这个网站是不通的。
当然我也可以选择百度,但是百度需要开发者KEY,有点麻烦啊。


代码如下:
SItude itude = new SItude();
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("http://www.google.com/loc/json");
try{
JSONObject holder = new JSONObject();
holder.put("version", "1.1.0");
holder.put("host","maps.google.com");
holder.put("address_language", "zh_CN");
holder.put("request_address", true);
holder.put("radio_type", "gsm");
holder.put("carrier", "HTC");
JSONObject tower = new JSONObject();
tower.put("mobile_country_code", cell.MCC);
tower.put("mobile_network_code", cell.MNC);
tower.put("cell_id",cell.CID);
tower.put("location_area_code", cell.LAC);

JSONArray towerarray = new JSONArray();
towerarray.put(tower);
holder.put("cell_towers", towerarray);

StringEntity query = new StringEntity(holder.toString());
post.setEntity(query);

/** 发出POST数据并获取返回数据 */
HttpResponse response = client.execute(post);
HttpEntity entity = response.getEntity();
BufferedReader buffReader = new BufferedReader(new InputStreamReader(entity.getContent()));
StringBuffer strBuff = new StringBuffer();
String result = null;
while ((result = buffReader.readLine()) != null)
{
strBuff.append(result);
}
/** 解析返回的JSON数据获得经纬度 */
JSONObject json = new JSONObject(strBuff.toString());
JSONObject subjosn = new JSONObject(json.getString("location"));

itude.latitude = subjosn.getString("latitude");
itude.longitude = subjosn.getString("longitude");

} catch (Exception e){
Toast.makeText(getApplicationContext(), "获取经纬度出现错误:"+e.getMessage(), Toast.LENGTH_SHORT).show();
}
...全文
355 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
pamgu 2017-03-06
  • 打赏
  • 举报
回复
引用 2 楼 wugamp 的回复:
除了百度和google,有没有别的网站提供基站定位服务啊?
当然有啊,高德的地图就是向瑞典购买的。
wugamp 2017-02-07
  • 打赏
  • 举报
回复
除了百度和google,有没有别的网站提供基站定位服务啊?
wugamp 2017-02-05
  • 打赏
  • 举报
回复
求大神回复啊!

80,471

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧