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

Alexandre Dube adube at mapgears.com
Thu Aug 7 07:55:08 EDT 2008


Sure I'll try, but anybody correct me if I am wrong with the explanation 
please.

The vertices are vector features too that try to be drawn on the same 
layer.  If a uniqueValueRules is set, then the a drawn feature must 
respect it.  Since the vertices don't ( they don't have the related 
attribute value, therefore don't respect the rule ) they are now drawn.

Well, in fact they are created, but not shown.  The elseFilter:true 
means : if the feature doesn't respect the uniqueValueRules, use "this" 
following rule instead.

Am I right ?

Alexandre

George.Muammar wrote:
> ALEX THAT WORKED JUST FINE!!!!!!! Great Stuff!
> Would you care to explain what the problem was ? For the record.
>
> Thanks to you and everyone else for the help.
>
>
>
> Alexandre Dube wrote:
>   
>> 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
>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>>
>>     
>
>   


-- 
Alexandre Dubé
Mapgears
www.mapgears.com




More information about the Users mailing list