ThinkGeo.com    |     Documentation    |     Premium Support

Controlling the Color of a Shape That's Being Drawn or Edited

We are trying to modify the color of the user drawn shapes during creation and editing.   Currently the app (and all of the example apps) has a green fill color when shapes are drawn and a blue/purple fill color when edited.  We can change the color obviously with a call after the shape is drawn, but what I am running into is that sometimes with our background maps, the default green and blue/purple are hard to see when creating and/or editing shapes.


What is the best way to modify these color?  We have tried changing the default styles for the Editlayer but that didn't seem to work.  Any help would be appreciated.


Thanks!


 



Clint,


We can change the color using Openlayers’ API on client part. Here is the sample code, copy it to the header tag of aspx page and it will work.

Notes: style['default'] is for features in normal status, style['select'] is for features in modification status.


 



      var OnMapCreating = function(map) {
            OpenLayers.Feature.Vector.style['default']['fillColor'] = '#ff6500';
            OpenLayers.Feature.Vector.style['default']['strokeColor'] = '#000000';
            OpenLayers.Feature.Vector.style['default']['pointRadius'] = '6';
            OpenLayers.Feature.Vector.style['default']['fillOpacity'] = '0.3';
            OpenLayers.Feature.Vector.style['default']['strokeWidth'] = '2';
            OpenLayers.Feature.Vector.style['default']['strokeOpacity'] = '0.5';

            OpenLayers.Feature.Vector.style['select']['fillColor'] = '#0065ce';
            OpenLayers.Feature.Vector.style['select']['strokeColor'] = '#000066';
            OpenLayers.Feature.Vector.style['select']['pointRadius'] = '6';
            OpenLayers.Feature.Vector.style['select']['fillOpacity'] = '0.6';
            OpenLayers.Feature.Vector.style['select']['strokeWidth'] = '2';
            OpenLayers.Feature.Vector.style['select']['strokeOpacity'] = '0.8';
        }

Also, please see the following link for the detail about the style.
dev.openlayers.org/releases/OpenLayers-2.7/doc/apidocs/files/OpenLayers/Feature/Vector-js.html
 
 
Thanks,
 
Ben

277-ChangeDefaultStyle.txt (1.05 KB)