[OpenLayers-Users] Problem with StyleMap

boesiii boesiii at yahoo.com
Fri Sep 6 06:36:56 PDT 2013


I am loading all my layers using a JSON file

{
"layers": [
{ "title":"Client Pipe 1" , "url":"./pipe1.geojson" , "style":"styleMap:
pipe1_stylemap"}, 
{ "title":"Client Pipe 2" , "url":"./pipe2.geojson" , "style":["styleMap:
pipe2_stylemap"]}
]
}

The layers are loading except for when it gets to the stylemap value.  I
have my stylemaps defined in my script before I load my layers.  I get
errors, "Object [object Array] has no method 'createSymbolizer' ".  What do
I need to add to my JSON file so it will interpret correctly?

-----predefined stylemap-----
var hydrant_stylemap = new OpenLayers.StyleMap ({
            'default': new OpenLayers.Style({
                pointRadius: 3,
                fillColor: "#9de24f",
                fillOpacity: 1,
                strokeColor: "#2da725",
                strokeWidth: 0.5            
            })                          
        });

-----layer loading----
for (var i in layer_data) {
                var layer_name = layer_data[i].title;
                //alert(layer_name);
                var layer_url = layer_data[i].url;
                //alert(layer_url);
                var layer_style = layer_data[i].style;
                //alert (layer_style);
                layer = new OpenLayers.Layer.Vector(layer_name, {
                    strategies: [new OpenLayers.Strategy.Fixed()],
                    protocol: new OpenLayers.Protocol.HTTP({
                        url: layer_url,
                        format: new OpenLayers.Format.GeoJSON({
                        })
                    }),
                    //styleMap: layer_style, // does not work here

                });
                //turn layer off
                layer.styleMap = layer_style; //does not work here either
                layer.setVisibility(false);
                map.addLayer(layer);
            }






--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Problem-with-StyleMap-tp5076474.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list