[OpenLayers-Dev] Chage style for "special marker" in ModifyFeature

Xavier Mamano (jorix) xavier.mamano at gmail.com
Tue Dec 31 08:33:11 PST 2013


Hi,

The drag tool (and all other tool created by the control: vertices to drag
...) has a property called "_sketch" (with _sketch = true), If you use a
style with context then could discriminate a different presentation for own
control tool that the points features in the layer.

NOTE: "_sketch" is not a API propierty!

EG: If you use this statement to create the layer in the
http://openlayers.org/dev/examples/modify-feature.html, the drag point will
be shown in red and the points and polygons of the layer blue:

vectors = new OpenLayers.Layer.Vector("Vector Layer", {
    renderers: renderer,
    styleMap: new OpenLayers.StyleMap({
        'default': new OpenLayers.Style(
            OpenLayers.Util.applyDefaults(
                    {fillColor: "${getColor}"},
                    OpenLayers.Feature.Vector.style['default']
            ), {
                context: {
                    getColor: function(feature) {
                        return feature._sketch ? "red" : "blue";
                    }
                }
            }
        )
    })
});

--------

I have developped a non standard code that makes the job simpler,
you can try here: 
  http://jorix.github.io/OL-Ragbag/examples/modify-feature.html
(to show a tool control do not use the style layer, uses the predefined and
customizable styles from the control)

Xavier


MorlDots wrote
> when use DRAG and etc how to change
> 1) standard style only for this marker
> 2) or establish its image instead of the "special marker"





--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Chage-style-for-special-marker-in-ModifyFeature-tp5095569p5095933.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.


More information about the Dev mailing list