On Fri, Aug 21, 2009 at 11:05 PM, Christopher Dale<[email protected]> wrote:
> Hey everyone,
>
> I'm running into another problem with this way of setting the vector
> layer's style. It looks like the editing handles are inheriting the
> styles from the vector layer as well, which makes for some nasty
> looking handles.
>
> Anyone know of a way to directly target the vector features themselves
> when setting the styles or else tell the editing toolbar layer not to
> inherit the styles from the default style?
>
> Here's an example of what I'm getting
>
> http://yfrog.com/74openlayers4g
I can't think of an easy way to achieve what you. I think we'd need to
extend the modify feature control to make the render intent of the
vertices configurable. In the mean time you can take a look at the
attached patch to the modify-feature.html example. This is a kinda
complex, but it works.
Hope this helps,
--
Eric Lemoine
Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex
Tel : 00 33 4 79 44 44 96
Mail : [email protected]
http://www.camptocamp.com
Index: examples/modify-feature.html
===================================================================
--- examples/modify-feature.html (revision 9628)
+++ examples/modify-feature.html (working copy)
@@ -22,8 +22,36 @@
map = new OpenLayers.Map('map');
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
- OpenLayers.Feature.Vector.style['default']['strokeWidth'] = '2';
- vectors = new OpenLayers.Layer.Vector("Vector Layer");
+
+ var template = OpenLayers.Util.applyDefaults({
+ "fillColor": "${fillColor}",
+ "strokeColor": "${strokeColor}",
+ "strokeWidth": "${strokeWidth}",
+ "cursor": "${cursor}"
+ }, OpenLayers.Feature.Vector.style["default"]);
+ var fn = function(property) {
+ return function(feature) {
+ var style = OpenLayers.Feature.Vector.style;
+ var geom = feature.geometry;
+ return feature._sketch &&
+ geom.CLASS_NAME == "OpenLayers.Geometry.Point" ?
+ style["select"][property] :
+ style["default"][property];
+ };
+ };
+ var context = {
+ "fillColor": fn("fillColor"),
+ "strokeColor": fn("strokeColor"),
+ "strokeWidth": fn("strokeWidth"),
+ "cursor": fn("cursor")
+ };
+ vectors = new OpenLayers.Layer.Vector("Vector Layer", {
+ styleMap: new OpenLayers.StyleMap({
+ "default": new OpenLayers.Style(template, {
+ context: context
+ })
+ })
+ });
map.addLayers([wms, vectors]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
@@ -51,7 +79,9 @@
regular: new OpenLayers.Control.DrawFeature(vectors,
OpenLayers.Handler.RegularPolygon,
{handlerOptions: {sides: 5}}),
- modify: new OpenLayers.Control.ModifyFeature(vectors)
+ modify: new OpenLayers.Control.ModifyFeature(vectors, {
+ virtualStyle: OpenLayers.Feature.Vector.style["select"]
+ })
};
for(var key in controls) {
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users