Chage style for "special marker" in ModifyFeature

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Chage style for "special marker" in ModifyFeature

MorlDots
This post has NOT been accepted by the mailing list yet.
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"
Reply | Threaded
Open this post in threaded view
|

Re: Chage style for "special marker" in ModifyFeature

Xavier Mamano (jorix)
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"