黑莓GPS获取当前位置的地址?

编程入门 行业动态 更新时间:2024-10-11 15:19:23
本文介绍了黑莓GPS获取当前位置的地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好,我是新来的黑莓应用程序development.I想得到当前GPS位置detail.I已经顺利拿到了纬度和经度,但我不知道如何获得当前address.can任何人给我一个样品?PLS感谢在前进。

Hi i am new to blackberry application development.I want to get current gps location detail.I had successfully got the latitude and longitude but i dont know how to get the current address.can any one give me a sample?Pls thanks in advance.

推荐答案

您可以使用谷歌地图来解决你的问题,如果你有一个lattitude和经度要求谷歌地图会根据您的选择返回JSON(或XML)。

You can use Google map to resolve your issue, Google map will return a JSON (or XML) according to your choice if you request with a lattitude and longitude.

网址是: maps.google/maps/geo?json&ll=+ _lattitude +,+ _longitude

这将返回JSON格式的特定纬度和经度的所有细节,而你要解析由谷歌地图返回的JSON。

This will return all the details of the given latitude and longitude in JSON format,And you have to parse the JSON returned by Google map.

您可以使用下面的code:

You can use the below code:

private void getLocationFromGoogleMaps() { try { StreamConnection s = null; InputStream iStream = null; s=(StreamConnection)javax.microedition.io.Connector.open("maps.google/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

Note: I use a FacebookBlackBerrySDK-0.3.5-src to parse JSON or you can XML aslo.

更多推荐

黑莓GPS获取当前位置的地址?

本文发布于:2023-11-28 08:58:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641761.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:当前位置   地址   黑莓   GPS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!