arcgis android之定位功能

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容