[OpenLayers-Users] Can Not Get Rule-based Stying to Work on KML
reinaldo at geodesign.com.br
reinaldo at geodesign.com.br
Thu Dec 6 11:34:27 PST 2012
OpenGSC,
Thanks for he advise, but I can't get it to work.
Please point out where I am wrong.
This my code now:
var map = new OpenLayers.Map("map");
var vector_style = new OpenLayers.Style({
fillColor: "#ffffff",
fillOpacity: 0.1,
strokeWidth: 1,
strokeColor: "#ffffff",
strokeOpacity: 4,
});
var ruleLow = new OpenLayers.Rule({
filter: new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.LESS_THAN,
property: "SUMMER",
value = 2000.0
}),
symbolizer: {
strokeColor: "#00ff00",
strokeWidth: 1,
fillColor: "#00ff00"
}
});
var ruleHigh = new OpenLayers.Rule({
filter: new OpenLayers.Filter.Comparison({
type: 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 vector_style_map = new OpenLayers.StyleMap({
'default': vector_style
});
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_map
});
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();
------------------------------------
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
>---- Original Message ----
>From: OpenGSC <945070223 at qq.com>
>To: openlayers-users at lists.osgeo.org
>Sent: Qui, Dez 6, 2012, 3:49 AM
>Subject: Re: [OpenLayers-Users] Can Not Get Rule-based Stying to Work on KML
>
>syleMap is not equal to style,your code is not correct.
>construt a styleMap and match the defalut attribute to you style.
>and Assign it to vectory layer's styleMap attribute
>
>
>
>--
>View this message in context: http://osgeo-org.1560.n6.nabble.com/Can-Not-Get-Rule-based-Stying-to-Work-on-KML-tp5021027p5021109.html
>Sent from the OpenLayers Users mailing list archive at Nabble.com.
>_______________________________________________
>Users mailing list
>Users at lists.osgeo.org
>http://lists.osgeo.org/mailman/listinfo/openlayers-users
More information about the Users
mailing list