2011-04-21 151 views
1

我曾用MidMap谷歌API按在我的項目下面給出的鏈接:http://www.jappit.com/blog/midmaps-g...va-me-library/J2ME +反向地理編碼

它是否工作正常。但是現在我想要做反向地理編碼。在我編程的地方通過經緯度和通過使用谷歌API我想獲得的地址(位置)。


編輯:我曾試圖實現這一點:

url="http://maps.googleapis.com/maps/api/geocode/xml?latlng=40.714224,-73.961452& sensor=true";    
    HttpConnection cnx = (HttpConnection)Connector.open(url);  
    InputStream is=cnx.openInputStream(); 
    StringBuffer b=new StringBuffer(); 
    int car; 
    while((car=is.read())!= -1){ 
     b.append((char)car); 
    } 
    is.close(); 
    cnx.close(); 
    String res=b.toString();</code></pre> 

它顯示在InputStream is=cnx.openInputStream();線的誤差。錯誤是:

java.io.IOException的:錯誤頭部
字段
在com.sun.midp.io.j2me.http.Protocol.readHeaders(),
BCI = 198
在com.sun.midp.io.j2me.http.Protocol.finishRequestGetResponseHeader(),
BCI = 45
在com.sun.midp.io.j2me.http.Protocol.sendRequest(),
BCI = 47
at com.sun.midp.io.j2me.http.Protocol.sendRequest(),
BCI = 3
在com.sun.midp.io.j2me.http.Protocol.openInputStream(),
BCI = 6
在httpmislet.run(httpmislet.java:46)
在java.lang中.Thread.run(),BCI = 11 java.io.IOException的:畸形
頭字段

我知道我需要使用XML解析。

+0

你能告訴你用哪個包的HttpConnection和連接器類?它是javax.microedition.io嗎? – 2013-01-04 11:49:54

回答

3

谷歌提供Reverse Geocoding (Address Lookup)還例如

http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true 
+0

感謝您的答覆。我試圖實現此網址=「http://maps.googleapis.com/maps/api/geocode xml?latlng = 40.714224,-73.961452&sensor = true」; HttpConnection cnx =(HttpConnection)Connector.open(url); InputStream = cnx.openInputStream(); StringBuffer b = new StringBuffer(); – shweta 2011-04-22 08:32:22

+0

歡迎您:) – 2011-04-22 08:32:59