Android Arcgis入門(九)、MapView定位當前的位置

利用MapView定位當前的位置

這裏要用到Arcgis中的LocationDisplayManager這個類,由於比較簡單。直接上代碼:

         LocationDisplayManager locationDisplayManager =  mMapView.getLocationDisplayManager();//獲取定位類
        locationDisplayManager.setShowLocation(true);
        locationDisplayManager.setAutoPanMode(LocationDisplayManager.AutoPanMode.LOCATION);//設置模式
        locationDisplayManager.setShowPings(true);
        locationDisplayManager.start();//開始定位

由於是定位,在AndroidManifest文件中,要添加以下權限:

     <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

另外如果我們想獲取定位點的位置,調用代碼:Point point = locationDisplayManager.getPoint();即可獲取。
定位當前位置

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章