[OpenLayers-Users] StyleMap and ModifyFeatures aren't
compatible ?
Alexandre Dube
adube at mapgears.com
Tue Aug 5 20:51:18 EDT 2008
Hi George,
Try to add the following lines :
==================
var rules = [new OpenLayers.Rule({
symbolizer: {strokeColor:"#FF0000",strokeWidth: 2},
// symbolizer: {}, // instead if you want to keep default colors
elseFilter: true
})];
styleMap.styles["default"].addRules(rules);
==================
Hope this can help you,
Cheers,
Alexandre
George.Muammar wrote:
> Hi List,
>
> I have a functional ModifyFeatures control working on a Vector layer.
>
> When I added a StyleMap to the vector layer (so I my features are coloured
> differently based on an attribute), the ModifyFeatures control does not work
> any more!
>
> The behaviour is this:
>
> polygons: when I click on the feature it get's selected (and it becomes 100%
> opaque) but no handles appear and there is no handle functionalities any
> more.
>
> paths: can't even select it
>
> points: everything ok (select and drag works).
>
>
> Did this happen to anyone ?
>
> Thanks
>
>
>
> Some code:
>
> here's how I define the style:
>
> var styleMap = new OpenLayers.StyleMap();
> var lookup = {
> 1: {fillColor: "green", fillOpacity: 0.3, strokeColor:
> "green",strokeWidth: 2},
> 2: {fillColor: "blue", fillOpacity: 0.3, strokeColor:
> "blue", strokeWidth: 2},
> 3: {fillColor: "red", fillOpacity: 0.3, strokeColor: "red",
> strokeWidth: 2}
> };
> styleMap.addUniqueValueRules("default", "attribute", lookup);
>
> vLayer = new OpenLayers.Layer.Vector("Vettori", {
> styleMap: styleMap
> });
>
>
> here's how I create my controls:
>
> function addControls()
> {
> vLayer.display(true);
> panel = new OpenLayers.Control.Panel({'displayClass':
> 'olControlEditingToolbar'});
>
>
> conts = {
> zoombox: new OpenLayers.Control.ZoomBox(),
>
> nav: new OpenLayers.Control.Navigation(),
>
> point: new OpenLayers.Control.DrawFeature(vLayer,
> OpenLayers.Handler.Point,
> {'displayClass': 'olControlDrawFeaturePoint',
> featureAdded:feature_added}),
>
> line: new OpenLayers.Control.DrawFeature(vLayer,
> OpenLayers.Handler.Path,
> {'displayClass': 'olControlDrawFeaturePath',
> featureAdded:feature_added}),
>
> polygon: new OpenLayers.Control.DrawFeature(vLayer,
> OpenLayers.Handler.Polygon,
> {'displayClass': 'olControlDrawFeaturePolygon',
> featureAdded:feature_added}),
>
> rectangle: new OpenLayers.Control.DrawFeature(vLayer,
> OpenLayers.Handler.RegularPolygon,
> {handlerOptions: {sides: 4, irregular: true},
> 'displayClass': 'olControlDrawFeatureRectangle',
> featureAdded:feature_added}),
>
> modify: new OpenLayers.Control.ModifyFeature(vLayer,
> {'displayClass': 'olControlModifyFeature',
> onModification: on_modification,
> mode: OpenLayers.Control.ModifyFeature.RESHAPE |
> OpenLayers.Control.ModifyFeature.DRAG |
> OpenLayers.Control.ModifyFeature.RESIZE |
> OpenLayers.Control.ModifyFeature.ROTATE})
>
> };
>
> for(var key in conts) {
> panel.addControls([conts[key]]);
> }
>
> panel.activateControl(conts.nav);
>
> layerSwitcher = new OpenLayers.Control.LayerSwitcher({'ascending':false});
> panZoomBar = new OpenLayers.Control.PanZoomBar()
> permalink = new OpenLayers.Control.Permalink('permalink');
>
> map.addControl( layerSwitcher );
> map.addControl( panZoomBar);
> map.addControl(permalink);
> map.addControl(panel);
>
> vLayer.display(true);
>
> }
>
>
>
--
Alexandre Dubé
Mapgears
www.mapgears.com
More information about the Users
mailing list