[OpenLayers-Users] StyleMap and ModifyFeatures aren't compatible ?

Arnd Wippermann arnd.wippermann at web.de
Tue Aug 5 13:09:23 EDT 2008


Perhaps the way you declare your styles. Try to add PointRadius:5 etc. to
your lookup array, whether it changes something.

Arnd Wippermann

-----Ursprüngliche Nachricht-----
Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von George.Muammar
Gesendet: Dienstag, 5. August 2008 11:50
An: users at openlayers.org
Betreff: [OpenLayers-Users] StyleMap and ModifyFeatures aren't compatible ?


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);
		
}


--
View this message in context:
http://www.nabble.com/StyleMap-and-ModifyFeatures-aren%27t-compatible---tp18
827878p18827878.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.

_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users




More information about the Users mailing list