[OpenLayers-Users] StyleMap, Style and Rules not working
Eric Lemoine
eric.lemoine at camptocamp.com
Sun Dec 27 10:18:10 EST 2009
On Mon, Dec 21, 2009 at 4:36 PM, Casper Børgesen <cbo at le34.dk> wrote:
> Looking at various examples of how to use styles in OpenLayers, we have
> built the following:
>
> var Layer_AddressWebService_1 = new OpenLayers.Layer.Vector(
> "AddressWebService_1",
> {
> styleMap: new OpenLayers.StyleMap(
> {
> "default": new OpenLayers.Style(
> {
> rules:
> [
> new OpenLayers.Rule(
> {
> symbolizer:
> {
> "Point":
> {
> pointRadius: 4,
> graphicName: 'square',
> fillColor: 'blue',
> fillOpacity: 1,
> strokeWidth: 1,
> strokeOpacity: 1,
> strokeColor: '#0000FF'
> }
> }
> })
> ]
> })
> })
> }, {
> displayInLayerSwitcher: false,
> isBaseLayer: false
> }
> );
>
> We think this should resemble and hopefully be functionally identical to:
>
> var awsSymbolizer = {
> "Point": {
> pointRadius: 4,
> graphicName: "square",
> fillColor: "blue",
> fillOpacity: 1,
> strokeWidth: 1,
> strokeOpacity: 1,
> strokeColor: "#0000FF"
> }
> };
>
> var awsStyle = new OpenLayers.Style();
> awsStyle.addRules([new OpenLayers.Rule({symbolizer: awsSymbolizer})]);
> var awsStyleMap = new OpenLayers.StyleMap({"default": awsStyle});
> var Layer_AddressWebService_1 = new
> OpenLayers.Layer.Vector("AddressWebService_1",
> {
> styleMap: awsStyleMap
> }, {
> displayInLayerSwitcher: false,
> isBaseLayer: false
> });
> But it is not. When using the latter, points are visualised fine, but using
> the first part, results in nothing. The problem lies around the rules. Can
> anyone tell me what the major difference is?
try
new OpenLayers.Style(null, {rules: [ /* */ ]});
^^^^
cheers,
--
Eric Lemoine
Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex
Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com
More information about the Users
mailing list