技术开发 频道

OPhone学习笔记 - 地图(3)

  二、程序功能

  首先要引入地图的库:

  并且要定义两个地图控制对象:

  private MapView mapView;

  private MapController mc;

  在按钮响应中添加:

mapView = (MapView) findViewById(R.id.myMap);
mapView.setTraffic(
true);
mc
= mapView.getController();

GeoPoint gp
= new GeoPoint((int) (Double.parseDouble(latText.getText().toString()) * 1000000), (int) (Double.parseDouble(lngText.getText().toString()) * 1000000));

  此处从文本框中获取经纬度坐标,转换成其标准格式。

  mc.animateTo(gp);

  mc.setZoom(Integer.parseInt(zm.getText().toString()));

  设置放大倍数。

0
相关文章