[OpenLayers-Users] Can Not Get Rule-based Stying to Work on KML

reinaldo at geodesign.com.br reinaldo at geodesign.com.br
Wed Dec 5 11:35:52 PST 2012


OL Users,

I am now trying to do rule-based styling, but am not getting anywhere. 

Can some one help?

I would like to apply styling base on rules, such as the examples:

var map = new OpenLayers.Map("map");

var vector_style = new OpenLayers.Style();

var ruleLow = new OpenLayers.Rule({
                    filter: new OpenLayers.Filter.Comparison
(http://OpenLayers.Filter.Comparison)({
                       type: OpenLayers.Filter.Comparison.LESS_THAN,
(http://OpenLayers.Filter.Comparison.LESS_THAN,)
                       property: "SUMMER",
                       value = 2000.0
                    }),
                    symbolizer: {
                      strokeColor: "#ff0000",
                      strokeWidth: 1,
                      fillColor: "#ff0000"
                    }
                });
var ruleHigh = new OpenLayers.Rule({
                    filter: new OpenLayers.Filter.Comparison
(http://OpenLayers.Filter.Comparison)({
                      type:
OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO,
(http://OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO,)
                      property: "SUMMER",
                       value = 2000.0
                    }),
                    symbolizer: {
                      strokeColor: "#ff0000",
                      strokeWidth: 1,
                      fillColor: "#ff0000"
                    }
                });

vector_style.addRules([ruleLow, ruleHigh]);

var vectorlayer = new OpenLayers.Layer.Vector("SOLAR RAD BA", {
        strategies: [new OpenLayers.Strategy.Fixed()],
        protocol: new OpenLayers.Protocol.HTTP({
            url: "kml/ba_diffuse_summer.kml",
            format: new OpenLayers.Format.KML({
               extractStyles: false,
               extractAttributes: true,
               srsName: "EPSG:900913"
            })
        }),
        styleMap: vector_style
});

var googleLayer = new OpenLayers.Layer.Google("Google Satellite",
            {type: google.maps.MapTypeId.SATELLITE, numZoomLevels: 22}
        );

map.addLayers([googleLayer, vectorlayer]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToMaxExtent();

I have a KML file with the following attributes for the features
(placemarks):
  ff0000ff  0
      cel_41355
      -39.33
      -8.514
      2354.6590
      3722.106
      2457.454
      2300.018
      1856.493
      1874.805
      1766.843
      2075.472
      2165.046
      2079.367
      2044.279
      2210.000
      2242.269
      2128.142
      2864.096
      2002.744
      1974.092
      -39.374898840000021,-8.532500220000012 
-39.368901960000017,-8.53460298000002 
-39.361320000000006,-8.539000020000019 
-39.357873000000019,-8.542680029999996 
-39.356818920000016,-8.546292000000021 
-39.352569839999994,-8.549219969999998 -39.345095880000024,-8.55734202 
-39.342219480000033,-8.558644590000013 
-39.373840080000008,-8.559807030000023 
-39.374898840000021,-8.532500220000012-39.328748280000021,-8.558149410000008
 -39.339051840000003,-8.558528130000013 
-39.331622880000026,-8.557507980000004 
-39.328748280000021,-8.558149410000008-39.311822160000034,-8.557527150000002
 -39.311876160000018,-8.557529130000008 -39.311844840000013,-8.55752202 
-39.311822160000034,-8.557527150000002
Thanks a lot.

Reinaldo
------------------------------------
 Reinaldo Escada Chohfi
 Sócio Gerente
 GeoDesign Internacional
 www.geodesign.com.br (http://www.geodesign.com.br)
 Tel./Fax: (12) 3153-5115
 Inteligência e Tecnologia Espacial de Ponta

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20121205/df951a5d/attachment.html>


More information about the Users mailing list