地圖縮放控制鈕

地圖縮放控制工具

提供設定地圖縮放控制工具,設定是否顯示地圖工具,設定程式範例如下:

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

AddMapView = (RelativeLayout)findViewById(R.id.AddMapView);

try {

_MapView = new TGOnlineMap(this);

 

_MapView.setBackgroundColor(Color.rgb(165,191,221));

AddMapView.addView(_MapView);

MapUiSetting = _MapView.getUiSetting();

//以下程式碼乃是控制 UiSetting

MapUiSetting.setScrollGesturesEnabled(true);

MapUiSetting.setZoomControlsEnabled(true);  //設定是否顯示地圖控制項

MapUiSetting.setZoomGesturesEnabled(true);

 

//[LocationAdapter]

_LocationAdapter = new TGLocationAdapter(this);

_LocationAdapter.AddLocationAdapterListener(this);

_LocationAdapter.setSpatialReference(_MapView.getMap().getSpatialReference());

//[SensorAdapter]

_SensorAdapter = new TGSensorAdapter(this);

_SensorAdapter.AddSensorAdapterListener(this);

//[MapGPSDisplay]

if(_MapGPSDisplay == null)

{

_MapGPSDisplay = new MapGPSDisplay(_MapView, _LocationAdapter, _SensorAdapter,

BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));

_MapGPSDisplay.setGPSPositionType(GPSPositionType.XY);

_MapView.getMapViewOverlays().add(_MapGPSDisplay);

 

_MapView.FullExtent();

_MapView.invalidate(true);

}

} catch (TGRuntimeRemoteException e) {

e.printStackTrace();

}

}

回到上方