[OpenLayers-Users] How to apply a style to a layer?

alex123 icidrop at yahoo.com
Tue Nov 15 10:16:43 EST 2011


Firstly, i want to say that i read the documentation of OL on this topic ,
but i fail to implement it correctly. 
My main goal is to edit the style of the data layer in my OSM server. This
is the code that i found in /site/index.html.erb:

*map = createMap("map");

    <% unless STATUS == :api_offline or STATUS == :database_offline %>
      map.dataLayer = new OpenLayers.Layer("<%= I18n.t
'browse.start_rjs.data_layer_name' %>", { "visibility": false});
      map.dataLayer.events.register("visibilitychanged", map.dataLayer,
toggleData);
      map.addLayer(map.dataLayer);
    <% end %>*

And this is what i tried to do:

map = createMap("map");

    <% unless STATUS == :api_offline or STATUS == :database_offline %>
     *var styleMap = new OpenLayers.StyleMap({'default': {strokeColor :
'#FF0000'}, 'select': {strokeColor : '#00FF00'} });*
      map.dataLayer = new OpenLayers.Layer("<%= I18n.t
'browse.start_rjs.data_layer_name' %>", { "visibility": false,* styleMap:
styleMap*});
      map.dataLayer.events.register("visibilitychanged", map.dataLayer,
toggleData);
      map.addLayer(map.dataLayer);
    <% end %>

Please give me some guidance on how to do this correctly. 

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/How-to-apply-a-style-to-a-layer-tp6996559p6996559.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list