Arcgis Map写入默认的纬度/经度位置

时间:2013-11-05 05:41:27

标签: java android arcgis esri

嗨,

我是开发ArcGIS地图的新手。目前,我可以显示地图。但是如何使用经度和纬度创建默认位置并在我的代码中实现呢?

例如,我想设置这些坐标:(1.3002,103.8641)。当您打开地图时,它会自动放大到这些坐标。

提前谢谢。

这是我的代码:

public class HelloWorld extends Activity {
MapView mMapView = null;
ArcGISTiledMapServiceLayer tileLayer;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // Retrieve the map and initial extent from XML layout
    mMapView = (MapView)findViewById(R.id.map);
    /* create a @ArcGISTiledMapServiceLayer */
    tileLayer = new ArcGISTiledMapServiceLayer(
            "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
    // Add tiled layer to MapView
    mMapView.addLayer(tileLayer);

}


@Override
protected void onPause() {
    super.onPause();
    mMapView.pause();
    }

@Override
protected void onResume() {
    super.onResume(); 
    mMapView.unpause();
}   

  }

1 个答案:

答案 0 :(得分:0)

在向MapView添加任何图层之前,请设置其OnStatusChangedListener。在地图坐标处向projects the longitude/latitude coordinates to map coordinatescenters the map的监听器添加代码。

你可以这样做:

mMapView = (MapView)findViewById(R.id.map);

final double longitude = 103.8641;
final double latitude = 1.3002;
mMapView.setOnStatusChangedListener(new OnStatusChangedListener() {

    @Override
    public void onStatusChanged(Object source, STATUS status) {
        if (STATUS.INITIALIZED.equals(status)) {
            Point mapPoint = GeometryEngine.project(longitude, latitude, mMapView.getSpatialReference());
            mMapView.centerAt(mapPoint, false);
        }
    }

});

/* create a @ArcGISTiledMapServiceLayer */
tileLayer = new ArcGISTiledMapServiceLayer(
        "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
// Add tiled layer to MapView
mMapView.addLayer(tileLayer);

如果您想要居中和缩放到一定比例,可以拨打zoomToScale而不是centerAt