Issue
I have implemented my own custom MapListener
for Polygons
and for Markers
in Nutiteq
and I can show Toasts
and change colors of elementsand other things but the listener doesn't react if I click long over a Marker or over a Polygon.
I have already tried with RegisterContextMenu, ContextMenuListener, etc outside my customListener and it was the same, it doesn't work.
My Intention is showing a ContextMenu
if I click long over an element(Marker/Polygon).
The code is the following
I have properly overriden the Methods
public class MyFieldEventListener extends MapListener {
private GeometryLayer layer;
private Marker clickMarker;
private MapView mapView;
private Activity activity;
public MyFieldEventListener(Activity activity, MapView mapView, GeometryLayer layer, Marker clickMarker) {
this.layer = layer;
this.clickMarker = clickMarker;
this.mapView = mapView;
this.activity = activity;
// I have also tried with this line commented and it's the same
mapView.setLongClickable(true);
// here I register my ContextMenu
activity.registerForContextMenu(mapView);
// Here I define my ContextMenuListener and create a ContextMenu
mapView.setOnCreateContextMenuListener( new View.OnCreateContextMenuListener() {
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
Log.i("TAG", "WmsMapActivity:: setOnCreateContextMenuListener.onCreateContextMenu");
menu.setHeaderTitle("Notes");
menu.add(0, 1, 0, "Write Text Note");
}
} );
}
@Override
public void onLabelClicked(VectorElement vectorElement, boolean longClick) {
if (vectorElement.getLabel() != null) {
if ( longClick )
mapView.showContextMenu();
else { // Another Stuff... }
}
@Override
public void onVectorElementClicked(VectorElement vectorElement, double x, double y, boolean longClick) {
if (vectorElement.getLabel() != null) {
if (longclick)
mapView.showContextMenu();
else { // Another Stuff... }
}
}
...
}
I would thank you for each Remark, Advise, etc
Kind Regards
Solution
Perhaps you disable click detection by calling mapView.getOptions().setClickTypeDetection(false) somewhere in your code? Other options should not interfere with click detection.
If that is not the case, I suggest you try Hellomap3D sample - it should show a toast when the displayed marker is clicked, with an indication whether it was a normal click or 'long' click. It works fine with my phone.
Answered By - MarkT
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.