繁体   English   中英

ArcgisMap写入默认纬度/对数位置

[英]ArcgisMap to write a default lat/log location

你好

我是开发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();
}   

  }

在将任何图层添加到MapView ,请设置其OnStatusChangedListener 将代码添加到侦听器,以将经度/纬度坐标投影到地图坐标并使地图居中于地图坐标。

您可以这样做:

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缩放到某个比例,可以调用zoomToScale而不是centerAt

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM