[OpenLayers-Users] externalGraphic rotation in a vector layer

Chander Ganesan chander.ganesan at gmail.com
Fri May 23 17:22:55 EDT 2008


Hi,

Give some advice by crschmidt on #openlayers, I tried to apply the patch 
specified in ticket #1433 to my installation of OpenLayer, and then 
tried to create a point with an externalGraphic and rotation angle.  
Unfortunately, this doesn't seem to work.  Here's the code that I used:

map = new OpenLayers.Map('map');
var ol_wms = new OpenLayers.Layer.WMS( "Metacarta Basic Layer",
                                             "http://labs.metacarta.com/wms/vmap0",
                                             {layers: 'basic'} );
ol_wms.maxExtent = new OpenLayers.Bounds(-125, 17.84, -59, 52.55);
ol_wms.displayOutsideMaxExtent = true;
var planes=new OpenLayers.Layer.Vector("Planes",
             {
             styleMap: new OpenLayers.StyleMap({ 
                        "default": { 
                                     externalGraphic: "airplane.gif", 
                                     graphicWidth: 24, 
                                     graphicHeight: 28, 
                                     graphicYOffset: 0, 
                                     rotation: "${angle}", 
                                     fillOpacity: "${opacity}" 
                                    }
                        })
             });

var extent = planes.map.getExtent();
var yspan = extent.getHeight();
var xspan = extent.getWidth();
var x = extent.left + xspan * Math.random();
var y = extent.top - yspan * Math.random();
var planeangle = Math.floor(Math.random() * 360);
var feature=new OpenLayers.Feature.Vector( new OpenLayers.Geometry.Point(x, y), {"angle": planeangle, 
                                                                                 opacity: 100 });
map.addLayers([ ol_wms , planes ]);
map.zoomToMaxExtent();


This code causes the layer to draw with the US map underneath, and the 
plane image to appear on the layer, but the image is not rotated.  Any 
ideas/thoughts?

thanks

chander



More information about the Users mailing list