arcgis android之定位功能的示例代碼
關(guān)于定位的功能,開發(fā),很早之前就有做過百度的定位功能。起初是有想法把百度的Loc V3.2的定位SDK整合進(jìn)來用。但是終歸是想法,但是知道昨天,我問技術(shù)群,里面的一位朋友就說起了百度地位SDK整合進(jìn)來的實(shí)現(xiàn)方法。頓時(shí),我就思考了一會,隨后就是很激動地操作起來。根據(jù)朋友給的一個demo。做了兩天,終于算是真正將功能實(shí)現(xiàn)了。至于界面的美觀或者樣式的顯示這個就偷懶掉了。
http://developer.baidu.com/map/sdk-android.htm
這個是百度的SDK。幫助文檔。
第一次看這個定位的實(shí)現(xiàn)的時(shí)候,覺得按步驟來就可以實(shí)現(xiàn),把該設(shè)置的參數(shù)設(shè)置好就行了。其實(shí),的確就行了。很簡單!
首先定位當(dāng)前經(jīng)緯度,然后設(shè)置定位點(diǎn)。
private double lat=-1;//緯度
private double lon=-1;//經(jīng)度
public class MainActivity extends ActivityBas{
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ArcGISRuntime.setClientId("1eFHW78avlnRUPHm");//取消arcgis默認(rèn)圖標(biāo)
dingweilocation();
mapView.centerAt(lat, lon, true);//設(shè)置定位中心點(diǎn)
mapView.setScale(1105828.1803422251);//設(shè)置顯示比例
}
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){
//這里做個判斷是因?yàn)?,可能因?yàn)間ps信號問題,定位出來的經(jīng)緯度不正常。
Log.i("定位",lat+"?"+lon);
lat = location.getLatitude();//緯度
lon = location.getLongitude();//經(jīng)度
}
}
@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用法。希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Android 物理游戲之重力系統(tǒng)開發(fā)示例代碼
介紹Android 物理游戲之重力系統(tǒng),這里提供了詳細(xì)的資料整理,并附示例代碼和實(shí)現(xiàn)效果圖,有興趣的小伙伴可以參考下2016-08-08
Android編程動態(tài)按鈕實(shí)現(xiàn)方法
這篇文章主要介紹了Android編程動態(tài)按鈕實(shí)現(xiàn)方法,分享了onTouch方法及xml調(diào)用兩種實(shí)現(xiàn)技巧,需要的朋友可以參考下2016-10-10
android studio 3.6.1導(dǎo)入項(xiàng)目報(bào)錯提示無法下載classpath里的內(nèi)容
這篇文章主要介紹了android studio 3.6.1導(dǎo)入項(xiàng)目報(bào)錯提示無法下載classpath里的內(nèi)容,本文通過原因分析通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-05-05
Android Intent傳遞數(shù)據(jù)底層分析詳細(xì)介紹
這篇文章主要介紹了Android Intent傳遞數(shù)據(jù)底層分析詳細(xì)介紹的相關(guān)資料,需要的朋友可以參考下2017-02-02
android自定義ListView實(shí)現(xiàn)底部View自動隱藏和消失的功能
本篇文章主要介紹了android自定義ListView實(shí)現(xiàn)底部View自動隱藏和消失的功能 ,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。2017-03-03

