隱藏地圖標記

隱藏地圖標記

建立地圖標記後,可進行標記之隱藏,隱藏地圖標記程式範例說明如下:

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);

_MapView.setOnInfoWindowClickListener(this);

_MapView.setOnMarkerClickListener(this);

_MapView.setOnMarkerDragListener(this);

 

NoMove = _MapView.addMarker(new TGMarkerOptions()

.position(new TGLatLng(24.4,120.0))

.title("title:Marker1")

.snippet("snippet:Marker1")

.draggable(false)

.icon(TGBitmapDescriptorFactory.fromResource(R.drawable.ic_launcher)));

 

canMove = _MapView.addMarker(new TGMarkerOptions()

.position(new TGLatLng(23.4,121.0))

.title("title:canMove")

.snippet("snippet:canMove")

.draggable(true)

.icon(TGBitmapDescriptorFactory.fromResource(R.drawable.ic_launcher)));

} catch (TGRuntimeRemoteException e) {

e.printStackTrace();

}

}

public void OnChangeMarkVisible(View v)

{

NoMove.setVisible(((CheckBox) v).isChecked());  //設置Marker是否顯示

canMove.setVisible(((CheckBox) v).isChecked());

_MapView.invalidate(true);  //設定完須更新畫面

}

回到上方