开发学院手机开发Android 开发 Android 通过地名获得经纬度并标识在地图上 阅读

Android 通过地名获得经纬度并标识在地图上

 2010-10-21 01:38:14 来源:WEB开发网   
核心提示:// 设置可以缩放map.setBuiltInZoomControls(true);Listaddresses = null;try {addresses = geo.getFromLocationName("江苏省苏州市寒山寺", 1);} catch (IOException e) {// TO

// 设置可以缩放

map.setBuiltInZoomControls(true);

List

addresses = null;

try {

addresses = geo.getFromLocationName("江苏省苏州市寒山寺", 1);

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

if(addresses.size() == 0) {

showDialog(ERROR_DIALOG);

GeoPoint geoBeijing = new GeoPoint(

(int) (39.906033* 1000000),

(int) (116.397700 * 1000000));

mapCon = map.getController();

mapCon.setCenter(geoBeijing);

mapCon.setZoom(4);

} else {

Address address = addresses.get(0);

// 设置初始地图的中心位置

GeoPoint geoPoint = new GeoPoint(

(int) (address.getLatitude() * 1000000),

(int) (address.getLongitude() * 1000000));

mapCon = map.getController();

mapCon.setCenter(geoPoint);

mapCon.setZoom(16);

List overlays = this.map.getOverlays();

overlays.add(new PositionOverlay(geoPoint, this, R.drawable.ic_red_pin));

}

}

@Override

protected boolean isRouteDisplayed() {

return false;

}

@Override

protected Dialog onCreateDialog(int id) {

return new AlertDialog.Builder(this).setTitle("查询出错哦")

.setMessage("路名/地名出错,请重新输入!").create();

}

class PositionOverlay extends Overlay {

private GeoPoint geoPoint;

private Context context;

private int drawable;

public PositionOverlay(GeoPoint geoPoint, Context context, int drawable) {

super();

this.geoPoint = geoPoint;

this.context = context;

this.drawable = drawable;

}

@Override

public void draw(Canvas canvas, MapView mapView, boolean shadow) {

上一页  1 2 3 4 5  下一页

Tags:Android 通过 地名

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接