[OpenLayers-Users] Layer rendering
Carlos Pinto
cmspinto at gmail.com
Wed Mar 5 09:51:46 EST 2008
Hi all,
Thanks very much. It is working and now I can start doing my grids.
the code is:
var styleMap = new OpenLayers.StyleMap({
fillOpacity: 1});
var lookup = {
0: {fillColor: "green", fillOpacity: 1, strokeColor: "green"},
1: {fillColor: "red", fillOpacity: 0.5, strokeColor: "red"}
}
styleMap.addUniqueValueRules("default", "type", lookup);
var mylayer = new OpenLayers.Layer.GML("GML",
"../KML/MyPolygons.xml",{styleMap: styleMap} );
map.addLayer(mylayer);
}
but one thing funny is that if I use the line
myLayer.styleMap = styleMap;
it does not work
Thanks all especially to Andreas.
On Wed, Mar 5, 2008 at 3:06 PM, Andreas Hocevar <andreas.hocevar at gmail.com>
wrote:
> Carlos,
>
> everything below is perfect, except that you need to add:
>
> <ms:type>1</ms:type>
>
> instead of
>
> <type>1</type>
>
> And yes, you should add the {styleMap: styleMap} options hash to your
> GML layer constructor. Or, after constructing the layer, just do
>
> myLayer.styleMap = styleMap;
>
> Regards,
> Andreas.
>
> Carlos Pinto wrote:
> > Hi all,
> >
> > then, if I use OpenLayers 2.6 I can use this feature, can I ask a help
> > of how then can I link the GML with the type?
> > and how can I format the color, transparency and set border of the
> > polygon?
> >
> > can I do like this?
> > Thanks for your help, Carlos
> >
> >
> > var lookup = {
> > 0: {fillColor: "green", fillOpacity: 0.7, strokeColor: "green},
> > 1: {fillColor: "red", fillOpacity: 0.7, strokeColor: "green"},
> >
> > 2: {fillColor: "#00ffff", fillOpacity: 0.7, strokeColor: "#00ffff"}
> >
> > }
> > styleMap.addUniqueValueRules("default", "type", lookup);
> >
> > // when I had the layer how do I say to apply the rules????
> > var mylayer = new OpenLayers.Layer.GML("GML",
> > "../KML/myPolygons.xml"); // should I add here in the end {styleMap:
> > styleMap}
> > map.addLayer(mylayer);
> >
> > So I have put the line * <type>1</type> * in the GML:
> >
> > <gml:featureMember>
> > <ms:polygon fid="2">
> > <gml:boundedBy>
> > <gml:Box srsName="EPSG:4326">
> > <gml:coordinates>0.511919,47.088176
> > 3.002191,48.882988</gml:coordinates>
> > </gml:Box>
> > </gml:boundedBy>
> > <ms:msGeometry>
> > <gml:Polygon srsName="EPSG:4326">
> > <gml:outerBoundaryIs>
> > <gml:LinearRing>
> > <gml:coordinates>7.25,54.25 7.75,54.25 7.75,54.75
> > 7.25,54.75 7.25,54.25</gml:coordinates>
> > </gml:LinearRing>
> > </gml:outerBoundaryIs>
> > </gml:Polygon>
> > </ms:msGeometry>
> > <ms:ogc_fid>2</ms:ogc_fid>
> > <ms:name>My box that is class1 </ms:name>
> > * <type>1</type> *
> > <ms:id>0</ms:id>
> > </ms:polygon>
> > </gml:featureMember>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080305/7f1a3d86/attachment.html
More information about the Users
mailing list