AW: [OpenLayers-Users] Re: changing style of layerusingradiobutton

Arnd Wippermann arnd.wippermann at web.de
Tue Mar 6 16:31:58 EST 2012


Hi,

You have only to set the new property and the value

In short:

function tematika (flag){

	if(flag==0)
	{
	hranice = zonyPrijem;
	polozka = polozkazonyPrijem;
	popis = popiszonyPrijem;
	}
	else if(flag==1)
	{
	hranice = zonyPopulace;
	polozka = polozkazonyPopulace;
	popis = popiszonyPopulace;
	}
	else if(flag==2)
	{
	hranice = zonyAL;
	polozka = polozkazonyAL;
	popis = "";
	}
	else if(flag==3)
	{
	hranice = zonyObrat;
	polozka = polozkazonyObrat;
	popis = "";
	}
	else if(flag==4)
	{
	hranice = zonyVlasy;
	polozka = polozkazonyVlasy;
	popis = "";
	}

	var selectStyle = new OpenLayers.Style({
					'strokeColor': '#ee1d99',
					'strokeWidth': 2,
					'cursor': 'default',
					'fillOpacity': pruhlednost,
					'graphicZIndex': 5
                    });

	style = new OpenLayers.Style({
	cursor: 'pointer',
	strokeWidth: 1,
	label: popis,
    fontColor: "black",
    fontFamily: "tahoma",
	fontSize: "7pt"});

			rule1 = new OpenLayers.Rule({
				filter: new OpenLayers.Filter.Comparison({
				type:
OpenLayers.Filter.Comparison.LESS_THAN,
				property: polozka,
				value: hranice[0]
				}),
				symbolizer: {fillColor: barvy[0],
				fillOpacity: pruhlednost,
				strokeColor: "black"}
				});

			rule2 = new OpenLayers.Rule({
				filter: new OpenLayers.Filter.Comparison({
				type: OpenLayers.Filter.Comparison.BETWEEN,
				property: polozka,
				lowerBoundary: hranice[0],
                upperBoundary: hranice[1]
				}),
				symbolizer: {fillColor: barvy[1],
				fillOpacity: pruhlednost,
				strokeColor: "black"}
				});

			rule3 = new OpenLayers.Rule({
				filter: new OpenLayers.Filter.Comparison({
				type: OpenLayers.Filter.Comparison.BETWEEN,
				property: polozka,
				lowerBoundary: hranice[1],
                upperBoundary: hranice[2]
				}),
				symbolizer: {fillColor: barvy[2],
				fillOpacity: pruhlednost,
				strokeColor: "black"}
				});

			rule4 = new OpenLayers.Rule({
				filter: new OpenLayers.Filter.Comparison({
				type: OpenLayers.Filter.Comparison.BETWEEN,
				property: polozka,
				lowerBoundary: hranice[2]+=1,
                upperBoundary: hranice[3]
				}),
				symbolizer: {fillColor: barvy[3],
				fillOpacity: pruhlednost,
				strokeColor: "black"}
				});

			rule5 = new OpenLayers.Rule({
				filter: new OpenLayers.Filter.Comparison({
				type:
OpenLayers.Filter.Comparison.GREATER_THAN,
				property: polozka,
				value: hranice[3]
				}),
				symbolizer: {fillColor: barvy[4],
				fillOpacity: pruhlednost,
				strokeColor: "black"}
				});

				style.addRules([rule1, rule2, rule3, rule4,
rule5]);

		styleAvon = new OpenLayers.StyleMap({'default': style,
'select': selectStyle});
        map.layers[2].styleMap = styleAvon;
        map.layers[2].redraw();
}

tematika (0);
 

-----Ursprüngliche Nachricht-----
Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von vrbikdan
Gesendet: Dienstag, 6. März 2012 21:46
An: openlayers-users at lists.osgeo.org
Betreff: Re: AW: [OpenLayers-Users] Re: changing style of
layerusingradiobutton

So if I understand well (and is really possible that I don't), I have to
write in every if new styleAvonPsc i.e. all five rules? It seems to me
little bit difficult. Or do you mean redefine style only: styleAvonPsc = new
OpenLayers.StyleMap({'default': style, 'select': selectStyle})?

Sorry for my stupid questions 

Dan

--
View this message in context:
http://osgeo-org.1560.n6.nabble.com/changing-style-of-layer-using-radiobutto
n-tp4507241p4552478.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