OpenLayers - Rotated PointVector with icon

Hello,
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
http://openlayers.org/dev/examples/styles-rotation.html

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);
pointVector.setIcon(e.getSource());
pointVector.setAttributes(attr);

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

Carl

Hi,

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:
http://dev.openlayers.org/releases/OpenLayers-2.12/doc/apidocs/files/OpenLayers/Symbolizer/Point-js.html#OpenLayers.Symbolizer.Point.rotation

cheers,
matti

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.setExternalGraphic("http://pinnaclecl.com/img/d9cd5c4c-955f-4550-a653-510017009b40.jpg");
aStyle.setProperty("rotation", 45);
sceneMarker.setCustomStyle(aStyle);

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:http://pinnaclecl.com/img/d9cd5c4c-955f-4550-a653-510017009b40.jpg,}

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

Any further help would be greatly appreciated

Carl

Hi,

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.

cheers,
matti

Hello,
Defining the graphics height and width worked a treat.

Thanks for the assist there, really appreciated.

Carl