[OpenLayers-Users] Rotate point with external graphic using drawFeature
mikeluz
paweluz at o2.pl
Fri Sep 13 06:23:47 PDT 2013
Hi
My goal is to draw a point on map that has a externalGraphic, and this
external graphic is rotated. I would like to do it with
OpenLayers.Control.DrawFeature. Each point has to have a different rotation
(random) . So:
1. I select drawing tool
2. I click on map (draw)
3. Each picture has different (random) rotation
This is my code:
/
var testLayer = new OpenLayers.Layer.Vector("test", {});
var controls = {
point: new OpenLayers.Control.DrawFeature(this.testLayer,
OpenLayers.Handler.Point, {
style: {
graphicWidth: 25,
graphicHeight: 25,
externalGraphic: 'images/sample.png',
rotation: "${angle}"
}
})
};/
This code below is to draw pictures on map. I got it from here:
http://www.netzwolf.info/assistent/tmp/drag-feature.htm
I added attribute angle additionally.
/
OpenLayers.Control.DrawFeature.prototype.drawFeature = function (geometry) {
var feature = new OpenLayers.Feature.Vector(geometry, {
angle: parseInt((Math.random() * 360).toFixed(0))
}, this.style);
var proceed = this.layer.events.triggerEvent("sketchcomplete", {
feature: feature
});
if (proceed !== false) {
feature.state = OpenLayers.State.INSERT;
this.layer.addFeatures([feature]);
this.featureAdded(feature);
this.events.triggerEvent("featureadded", {
feature: feature
});
}
};/
I think it should work, but somehow it does not....
Regards,
Pawel
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Rotate-point-with-external-graphic-using-drawFeature-tp5077702.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list