Styling a Point WFS Layer

118 views
Skip to first unread message

Markus Wagner

unread,
Mar 31, 2010, 2:33:20 AM3/31/10
to openscales-dev
Hi @ all,

i have a problem with styling my point layers.
Is there a possibility to set different styles to a point layer
( different colors/ size ) depending on rules?

I styled my polygones with 5 rules ( 5 different colors and shapes),
but i don´t know how to start with the point layer.

Romaric Pascal

unread,
Mar 31, 2010, 3:46:32 AM3/31/10
to opensca...@googlegroups.com
Hi !

You can apply the same principles for styling your point layers : create multiple rules with different styling and use filter to assign them to the correct category of points.

Romaric

2010/3/31 Markus Wagner <markuswa...@googlemail.com>

--
You received this message because you are subscribed to the Google Groups "openscales-dev" group.
To post to this group, send email to opensca...@googlegroups.com.
To unsubscribe from this group, send email to openscales-de...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/openscales-dev?hl=en.


Markus Wagner

unread,
Mar 31, 2010, 4:05:42 AM3/31/10
to openscales-dev
Hi,

i had the problem that i need to define the pointstyle itself (square,
circle,...). I found out that i need the WellKnownMarker right now ;-)
It works. But how do i use a picture (bitmap/jpeg,...) for example?

Markus Wagner

unread,
Mar 31, 2010, 5:50:44 AM3/31/10
to openscales-dev
Sry but i have another question:

i can´t find the default mouseOver function. I wanted to change the
moseOver color (points / polygones) from the standard yellow to
another.

Anybody an idea how to solve it?

PS: writing an new mouseOverListener and set it to a new style, slows
the whole application, so that this is not the right way ;-)

Romaric Pascal

unread,
Mar 31, 2010, 6:53:05 AM3/31/10
to opensca...@googlegroups.com
You may want tot take a look at the Global example of the openscales demo, as what it does is, I think, quite similar to what you want to achieve : changing the style of a feature when mouse comes over it (the example uses the SelectFeatureHandler class).

Another option you have is to create a custom class extending Marker to use in the style definition. This class would have its generateGraphic() method return a display object with appropriate listeners on it for having the behaviour you want. This is also the way to have your point features render defined by an image : you create a custom marker with its generateGraphic method returning instances of the image you'd like to be displayed (stored as a BitmapData for example).

Romaric


2010/3/31 Markus Wagner <markuswa...@googlemail.com>
Sry but i have another question:

Markus Wagner

unread,
Mar 31, 2010, 8:04:40 AM3/31/10
to openscales-dev
Hi again,

i have theSelectFeaturesHandler implemented yet,
(<os:SelectFeaturesHandler id="SFH" active="true"
enableClickSelection="false" enableBoxSelection="false"
enableOverSelection="true" />)

and i know that the property "enableOverSelection" enables the
stylechange on mouseover, but how or where do i specify the style?

[Sry for my inexperience, i´m very new to GIS]

Romaric Pascal

unread,
Mar 31, 2010, 8:20:27 AM3/31/10
to opensca...@googlegroups.com
The SelectFeaturesHandler has a defaultSelectedStyle property ((as you use the Flex class, it may not be available as a property of the Flex object, but can be accessed through its handler property, with something like "SFH.handler.defaultSelectedStyle") that stores a function returning the style to use for selected feature.

So using you own function that returns your custom style should do the trick !

2010/3/31 Markus Wagner <markuswa...@googlemail.com>

--

Markus Wagner

unread,
Mar 31, 2010, 10:03:00 AM3/31/10
to openscales-dev
Ok i had a try to your solution:

<os:SelectFeaturesHandler id="SFH" active="true"
enableClickSelection="false" enableBoxSelection="false"
enableOverSelection="true" />

Is from org.openscales.fx.handler.feature.FxSelectFeaturesHandler.
-> can´t get the "handler.defaultSelectedStyle" property/attribute.

I created a separate SelectFeaturesHandler from
or.openscales.core.handler.feature.SelectFeaturesHandler.
The handler.defaultSelectedStyle is now reachable. Within a
eventhandler that pop ups when i mouse over a feature
[SelectFeaturesHandler.defaultSelectedStyle(event.feature);] i get the
style that the feature has.
In my example is the name: "Default Feature Style".

Now the question: where is the "Default Feature Style" defined and how
can i overwrite it?
I just wanted to set the yellow overColor to another, nothing else,
and it seems to be unsolveable for me ;-)

Romaric Pascal

unread,
Mar 31, 2010, 10:32:24 AM3/31/10
to opensca...@googlegroups.com
The "Default Feature Style" is obtained through Style.getDefaultPolygonStyle if I remember well.

Now that you have access to the defaultSelectedStyle property, you need to set it to a function that returns your custom style and this should be all.

Changing styles "on the fly" does not really seem programmer friendly a lot. We'll try to improve it in future releases of the API.

Romaric

2010/3/31 Markus Wagner <markuswa...@googlemail.com>
Ok i had a try to your solution:

--

Markus Wagner

unread,
Mar 31, 2010, 11:48:59 AM3/31/10
to openscales-dev
Neverending story:

private function blub(event:FeatureEvent):void {
var fill:SolidFill = new SolidFill(0xba122b, 2);
var stroke:Stroke = new Stroke(0xFFFFFF, 9);
var wkm:WellKnownMarker = new
WellKnownMarker(WellKnownMarker.WKN_SQUARE, fill, stroke);
wkm.size = 15;
var ps:PointSymbolizer = new PointSymbolizer();
ps.graphic = wkm;
var ru:Rule = new Rule();
ru.name = "Default rule43";
var st:Style = new (Style);
st.name = "Default point style22";
st.rules.push(ru);


SelectFeaturesHandler.defaultSelectedStyle(event.feature).rules.push(ru);
SelectFeaturesHandler.defaultSelectedStyle(event.feature).rules =
st.rules;

SelectFeaturesHandler.defaultSelectedStyle(event.feature).name =
"test";


Alert.show(SelectFeaturesHandler.defaultSelectedStyle(event.feature).rules.length.toString());
}

Nothing happen in the last 4 rows.
->SelectFeaturesHandler.defaultSelectedStyle(event.feature).name =>
returns me allways the name of the default rule
-
>SelectFeaturesHandler.defaultSelectedStyle(event.feature).rules.length.toString()
=> returns always 1

Is there a restriction to override the incoming values?

Ive tried to ovverride the class: SelectFeaturesHandler, but with no
success. It also seems that i have no permission. My sample code:

public class SelectFeaturesHandler extends
org.openscales.core.handler.feature.SelectFeaturesHandler {}

After that line i got a 1017 error, because
"org.openscales.core.handler.feature.SelectFeaturesHandler" could not
be find.

Thank you very much for the last answers and your patience.
I looking forward to solve my problem.

Markus Wagner

unread,
Apr 6, 2010, 7:03:36 AM4/6/10
to openscales-dev
No one an idea?

Romaric Pascal

unread,
Apr 6, 2010, 7:35:27 AM4/6/10
to opensca...@googlegroups.com
You have to define a method that will "replace" the default defaultSelectedStyle method and then assign it to the handler. Something like : 

function myCustomStyle(feature:Feature):Style{

var s:Style = new Style();

// Your custom style creation here

return s;
}

(SFX.handler as SelectFeatureHandler).defaultSelectedStyle = myCustomStyle;




2010/4/6 Markus Wagner <markuswa...@googlemail.com>
No one an idea?

Munna

unread,
Mar 27, 2012, 4:47:48 AM3/27/12
to opensca...@googlegroups.com
@Markus,

I am also facing same problem, i want to change the styles of the point layer with 4 rules. any code for this.
where i have to define the rules and how.

how can i use a bitmap/gif as point.

thanks in advance...

WillPetty

unread,
Mar 30, 2012, 10:55:43 AM3/30/12
to opensca...@googlegroups.com
The easiest way to use a image as a point is to define the image as a class and use  that class in DisplayObjectMarker.
here is an example.. after you define your WFS layer..


             var point:DisplayObjectMarker =  new DisplayObjectMarker(imageClass);
            var symbolizer:PointSymbolizer = new PointSymbolizer();
            symbolizer.graphic = point;
             var rule:Rule = new Rule();
            rule.symbolizers.push(symbolizer);
             var style:Style = new Style();
            style.rules.push(rule);
            wfs.style = style;
            map.addLayer(wfs);   

hope that helps.

-Will

nanda kishor

unread,
Apr 2, 2012, 2:53:37 AM4/2/12
to opensca...@googlegroups.com
Hello Will,

Thanks for your reply...

I have defined WFS layer.
I am not getting where i have to define the style.
this is my code..
<os:Map id="fxmap1" height="100%" width="100%" >

<os:WMS name="KarnatakaState" 
layers=" nurc:mosaic
format="image/jpeg" 
isBaseLayer="true">
</os:WMS>

<os:WFS name="AWSPOINTS" 
typename="Final:1sep11" 
projection="EPSG:4326" 
version="1.0.0" 
useCapabilities="true" 
capabilitiesVersion="1.0.0" 
style="{Style.getDefaultPointStyle()}">
</os:WFS>
</os:Map>

my WFS layer contains the rainfall information. I wanted to set a 4 rules for the quantity of rainfall and i need to show 4 jpeg image as the points for 4 rules, like for 
Rule1 is rainfall 0 to 25 rain1.jpeg
Rule2 is rainfall 25 to 50 rain2.jpeg
Rule3 is rainfall 50 to 75 rain4.jpeg 
Rule4 is rainfall 75 to 100 rain5.jpeg

my WFS layer contains data as,

name       lat        long     rainfall
A             13         70        15
B             14         70        80
C             15         70        30
D             16         70        58
E             13.5      70        70

Thanks in advance........


--
You received this message because you are subscribed to the Google Groups "openscales-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/openscales-dev/-/8a4r8n-DngMJ.

To post to this group, send email to opensca...@googlegroups.com.
To unsubscribe from this group, send email to openscales-de...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/openscales-dev?hl=en.



--

- Regards
  NANDA KISHOR.K.S
  M.Tech (RS & GIS)
  09738120522
  09986715366


Reply all
Reply to author
Forward
0 new messages