Arcgis android 100.2.0本地坐标自定义定位
一般定位就是不断的添加和remove graphic,今天get了一个新技能,就是自定义定位数据源。
自定义个一个类继承LocationDataSource,如下:
public class CustLocationDataSource extends LocationDataSource {
@Override
protected void onStart() {
onStartCompleted(null);
}
@Override
protected void onStop() {
}
public CustLocationDataSource() {
super();
}
//外部调用进行坐标更新
public void UpdateLocation(LocationDataSource.Location location){
this.updateLocation(location);
}
}
------------------------------------------------------------------------
// 设置定位数据源
m_datasource = new CustLocationDataSource();
mapView.getLocationDisplay().setShowLocation(true);
mapView.getLocationDisplay().setShowPingAnimation(true);
mapView.getLocationDisplay().setLocationDataSource(m_datasource);
//显示自定义的定位符号
Drawable drawable = this.getResources().getDrawable(R.mipmap.mapLoc);
final PictureMarkerSymbol symbol = new PictureMarkerSymbol((BitmapDrawable)drawable);
symbol.loadAsync();
symbol.addDoneLoadingListener(new Runnable() {
@Override
public void run() {
mapView.getLocationDisplay().setDefaultSymbol(symbol);
mapView.getLocationDisplay().startAsync();
}
});
一旦位置有更新,直接调用m_datasource.UpdateLocation