android GoogleMap定位(四)(2)
来源:未知 责任编辑:责任编辑 发表时间:2013-11-17 14:39 点击:次
Toast.makeText(AddressActivity.this, "输入有效地址",
Toast.LENGTH_LONG).show();
} else {
double[] result=ConvertUtil.getLocationInfo(address);
UpdateMapView(result[0], result[1]);
}
}
});
locBn.performClick();
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return true;
}
private void UpdateMapView(double dlong, double dLat) {
GeoPoint gp = new GeoPoint((int)(dLat*1E6), (int)(dlong*1E6));
mv.displayZoomControls(true);
controller.animateTo(gp);
List<Overlay> ol = mv.getOverlays();
ol.clear();
ol.add(new PosOverLay(gp, posBitmap));
}
}
处理请求(推荐此处用service,handle来进行处理交互)
package com.hc;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONException;
import org.json.JSONObject;
public class ConvertUtil {
public static double[] getLocationInfo(String address){
HttpClient client= new DefaultHttpClient();
HttpGet httpGet=new HttpGet("http://maps.google.com/maps/api/geocode/json?address="+address+"ka&sensor=false");
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>