嗨,我是黑莓应用程序开发的新手。我想获得当前的gps位置细节。我已经成功地获得了经纬度,但我不知道如何获得当前的地址。任何人都可以给我一个样本?请感谢提前。blackberry gps获取当前位置地址?
1
A
回答
3
你在找什么叫做“反向地理编码”。 RIM在BB平台上有一个example of exactly how to do this(好吧,无论如何要做到这一点)。
3
您可以使用Google地图解决您的问题,如果您请求经度和纬度,Google地图将根据您的选择返回JSON(或XML)。
的网址是:http://maps.google.com/maps/geo?json&ll="+_lattitude+","+_longitude
这将返回JSON格式的给定的纬度和经度的所有细节,而且你必须解析由谷歌地图返回的JSON。
您可以使用下面的代码:
private void getLocationFromGoogleMaps() {
try {
StreamConnection s = null;
InputStream iStream = null;
s=(StreamConnection)javax.microedition.io.Connector.open("http://maps.google.com/maps/geo?json&ll="+_lattitude+","+_longitude+getConnectionStringForGoogleMap());//&deviceside=false&ConnectionType=mds-public"
HttpConnection con = (HttpConnection)s;
con.setRequestMethod(HttpConnection.GET);
con.setRequestProperty("Content-Type", "//text");
int status = con.getResponseCode();
if (status == HttpConnection.HTTP_OK)
{
iStream=s.openInputStream();
int len=(int) con.getLength();
byte[] data = new byte[8000];
byte k;
String result="";
while((k = (byte)iStream.read()) != -1) {
result = result+(char)k;
}
try {
JSONObject jsonObjectMapData=new JSONObject(result);
JSONArray jsonaryPlaceMark = jsonObjectMapData.getJSONArray("Placemark");
JSONObject address= jsonaryPlaceMark.getJSONObject(0);
String placeName=address.getString("address");
if(placeName!=null)
lblLoc.setText(address.getString("address"));
else
lblLoc.setText("Location information currently unavilable");
} catch (Exception e) {
lblLoc.setText("location information Currently Unavilable");
}
}
}catch (Exception e) {
System.out.println(e);
lblLoc.setText("location information Currently Unavilable");
}
}
注:我使用的是FacebookBlackBerrySDK-0.3.5-SRC解析JSON或我们可以将XML ASLO。
相关问题
- 1. 在BlackBerry上获取当前GPS坐标
- 2. 获得GPS当前位置
- 3. 在BlackBerry上获取GPS位置
- 4. 使用GPS获取当前位置
- 5. 从GPS获取当前位置
- 6. 在GPS中获取当前位置?
- 7. 如何获取当前的GPS位置?
- 8. 获取当前位置(GPS/WIFI)
- 9. 获取当前GPS位置android studio
- 10. GPS当前位置
- 11. Google地图 - 获取当前地图位置的地址
- 12. 使用GPS获取当前位置时不显示地图
- 13. android gps当前位置
- 14. Gps当前位置问题
- 15. 在android中使用GPS获取当前地址?
- 16. 获取当前用户位置的地址
- 17. 获取谷歌地图当前位置
- 18. 获取当前位置的Google地图
- 19. 在地图上获取当前位置
- 20. Android - 可靠地获取当前位置
- 21. 获取GPS位置
- 22. 获取地址的位置
- 23. 获取当前位置
- 24. 获取当前位置
- 25. 获取当前位置
- 26. 获取当前位置
- 27. 获取当前位置android
- 28. 获取当前位置ImageView
- 29. Android获取当前位置
- 30. android获取当前位置
我该如何检查值?在可运行的线程内没有字段允许像(labelfield,textfield)如何检查addrinfo值?请回复我 – 2011-04-08 13:33:09
这听起来像你应该做一些调查在BB应用中使用线程。例如,您可能会看到Blackberry UI线程 - 非常基础:http://www.thinkingblackberry.com/archives/182 – 2011-04-08 16:02:16