點擊標記事件
點擊標記事件
點擊標記觸發事件,於點擊標記時觸發,程式範例說明如下:
public class MainActivity extends Activity implements OnInfoWindowClickListener, OnMarkerClickListener ,OnMarkerDragListener{
RelativeLayout AddMapView;
TGOnlineMap _MapView = null;
@Override
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);
//設定Marker
TGMarker 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)));
TGMarker 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();
}
}
@Override
public void onInfoWindowClick(TGMarker arg0) {
Toast.makeText(this, "onInfoWindowClick:"+arg0.getTitle(), Toast.LENGTH_LONG).show();
}
@Override
public void onMarkerClick(TGMarker arg0) { //點擊Marker時觸發
Toast.makeText(this, "onMarkerClick:"+arg0.getTitle(), Toast.LENGTH_LONG).show();
}
@Override
public void onMarkerDrag(TGMarker arg0) {
Log.i("Marker", arg0.getTitle()+":Dragging");
}
@Override
public void onMarkerDragEnd(TGMarker arg0) {
Log.i("Marker", arg0.getTitle()+":Drag End");
}
@Override
public void onMarkerDragStart(TGMarker arg0) {
Log.i("Marker", arg0.getTitle()+":Drag Start");
}
}