OpenLayers Wrapper-Addon- Point Vector Right click

Hi ,
I am using OpenLayers add-on with vaadin 6.7.10.
I need to implement context menu on the right click on a point vector or polyline.
is there any solution for this?

Hi,

I think currently only the actual map has context menu (aka Actions) support. The target parameter in handleAction is the point where the context menu was opened. So in theory you could seek the relevant vector on the server side.

cheers,
matti

Hi Matti,
thank you for the quick reply.
My problem with the suggested solution is that, I have many point vectors in the same layer, and each point vector is differentiated by a type and the context menu depends on this type. In addition I may have more than one point vectors at the same point. So by seeking the vector layer for the clicked point may result more than one point vectors and I dont’ know which is actually clicked.

Is there any idea to add a new listener similar to VectorLayer.VectorSelectedListener but for mouse events?

On the other hand, I am using the caption and description properties for the point vector, but actually there is noting displayed on the map, any idea?

I also have the problem that mentioned in the
Thread
any suggestion also?

Regards,
Nebras.

Hi,

If you have (really) lots of vectors and different context menu options fo each, then the Action interface (the default context menu) don’t really play well for you. The problem is that it eagerly checks for available context menu options and to me it sounds like a lazy method would be better. That is really not my favourite invention in Vaadin framework :slight_smile:

It would probably be better to check if Peters ContextMenu addon ( https://vaadin.com/directory#addon/contextmenu:vaadin ) could be hooked somehow. It will probably need changes to OpenLayers add-on as well.

Vectors could indeed be extended to support various mouse events, but so far I thing everybody has been enough satisfied with selection listener. You can use it like click listener if you in selection event always deselect the feature. Maybe you could add your “actions” into a sub window placed near to your feature?

For the other threads issue, there is not much can do if there is no good test case for the problem.

cheers,
matti

Hi Matti,
I am working on adding a new click listener on vector. I have added the below code to VVectorLayer class:
vectors.registerHandler(“featureclicked”, new GwtOlHandler() {
@SuppressWarnings(“rawtypes”)
public void onEvent(JsArray arguments) {
if (updating) {
// ignore selections that happend during update, those
// should be already known and notified by the server
// side
return;
}
if (client.hasEventListeners(VVectorLayer.this, “vclick”)) {
ValueMap javaScriptObject = arguments.get(0).cast();
Vector vector = javaScriptObject.getValueMap(“feature”)
.cast();
for (Widget w : getChildren()) {
VAbstractVector v = (VAbstractVector) w;
if (v.getVector() == vector) {
client.updateVariable(paintableId, “vclick”, v,
true);
}
}
client.updateVariable(paintableId, “mdetails”, “”,
true);
}
}
});
and added a new event in VectorLayer that will be fired based on the value of “vclick” variable.
But actually nothing happened.
any advise please?