OpenLayers - Rotated PointVector with icon

I am trying to produce a rotated PointVector with an icon (Using a FileResource) but the icon doesn’t come through and since the default icon is a circle I can’t tell if the rotation is being applied.

The output I am looking for is similar to the OpenLayer example

Below is the code I’m using to create the PointVector:

FileResource resource = new FileResource(file,getApplication());
Attributes attr = new Attributes();
attr.setProperty("rotation", 45);
PointVector pointVector = new PointVector(latitude,longitude);

Where file is just a normal Java IO File and the PointVector gets added to a vector layer.

Am I making the wrong call or have I missed something?

Any help would be appreciated



The icon stuff seems to be the most common part where developers fail with VOL Vectors currently. The setIcon method you are using is coming from bloated Vaadin Component API and it is not used by OL vectors. We should probably at least document this better by overriding javadocs, but we could also try to build a support for it also. Anyways, currently you need to use setExternalGraphic method in org.vaadin.vol.Style. The Demo class in the add-on project has example of this. The sad thing is that it doesn’t yet support generic Vaadin Resources, just raw URL:s.

Also the rotation should be set in that same class. There is no typed API for it, but things should work fine with the setProperty(String,Object) method. Related OL API is here:


Thank you for the reply, pointed me in the right direction.

I’ve amended my code to use the Style object for setting the external graphic and rotation but I’m not getting anything on screen.

Code below:

sceneMarker = new PointVector(latitude,longitude);
Style aStyle = new Style();
aStyle.setProperty("rotation", 45);

Without the external graphic the normal circle appears.

With the debug on the PointVector in question prints out:

org.vaadin.vol.client.ui.VPointVector id=PID215 points={0:-2.0377492904663086:57.2133344122731,} olStyle={rotation:45,__VOL_INHERIT:default,externalGraphic:,}

The image is just a random image and is 100 x 75.

Any further help would be greatly appreciated



I added an example how to do this to
project tests
. I needed to specify the graphic size, which I assume is an OL requirement.


Defining the graphics height and width worked a treat.

Thanks for the assist there, really appreciated.