arcgis android之定位功能

作者: 奋斗的犇犇 | 来源:发表于2018-04-16 16:34 被阅读65次

arcgis android定位功能很简单,首先定位当前经纬度,然后设置定位点。

   private double lat=-1;//纬度
   private double lon=-1;//经度
 public class MainActivity extends ActivityBas{
        protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
   ArcGISRuntime.setClientId("1eFHW78avlnRUPHm");//取消arcgis默认图标
    dingweilocation();
   mapView.centerAt(lat, lon, true);//设置定位中心点
    mapView.setScale(1105828.1803422251);//设置显示比例
    }


private void dingweilocation() {
       //定位的方法
    LocationDisplayManager locationDisplayManager = mapView.getLocationDisplayManager();
    locationDisplayManager.setLocationListener(new LocationListener() {
        @Override
        public void onLocationChanged(Location location) {
            
            String bdlat=location.getLatitude()+""; 
            String bdlon=location.getLongitude()+"";
            if (bdlat.indexOf("E")==-1|bdlon.indexOf("E")==-1){
           //这里做个判断是因为,可能因为gps信号问题,定位出来的经纬度不正常。
                Log.i("定位",lat+"?"+lon);
                lat = location.getLatitude();//纬度
                lon = location.getLongitude();//经度

            }

        }

        @Override
        public void onStatusChanged(String s, int i, Bundle bundle) {

        }

        @Override
        public void onProviderEnabled(String s) {

        }

        @Override
        public void onProviderDisabled(String s) {

        }
    });
    locationDisplayManager.start();
}
 }

好了,今天就写到这里,以后我再介绍其他arcgis用法。有这方便开发经验的同行们我期待和你们的交流:
qq群:428600570

相关文章

网友评论

    本文标题:arcgis android之定位功能

    本文链接:https://www.haomeiwen.com/subject/ofxckftx.html