[OpenLayers-Users] Layer rendering

Carlos Pinto cmspinto at gmail.com
Fri Feb 29 05:18:49 EST 2008


Hi all,

I have try to use SLD but I was missing something.

Then I try to apply the  style and wen I put this line:


var styleMap = new OpenLayers.StyleMap(OpenLayers.Util.extend(
        {fillColor: "green", fillOpacity: 1, strokeColor: "black"},
        OpenLayers.Feature.Vector.style["default"]);

the map just stop working :(

The problem is so simple and I can't get a solution, I have a gml file with
300 polygons but with only 20 classes and I just want to make each class
with diferent collor, in this example I have two squares with class 2 should
be red and class 3 green but when I make load the sld file for this simple
example nothing happens and when I try the style the map doesn't show, the
gml file:

Thanks in advance for any help.

<?xml version="1.0" encoding="ISO-8859-1"?>
<wfs:FeatureCollection xmlns:ms="http://mapserver.gis.umn.edu/mapserver"
xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml"
xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd
http://mapserver.gis.umn.edu/mapserver
http://aneto.oco/cgi-bin/worldwfs?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=polygon&amp;OUTPUTFORMAT=XMLSCHEMA
">
      <gml:boundedBy>
          <gml:Box srsName="EPSG:4326">
              <gml:coordinates>-0.768746,47.003018 3.002191,47.925567
</gml:coordinates>
          </gml:Box>
      </gml:boundedBy>

    <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>Meu quadrado</ms:name>
        <ms:id>0</ms:id>
      </ms:polygon>
    </gml:featureMember>

    <gml:featureMember>
      <ms:polygon fid="3">
        <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>1.75,53.25 2.25,53.25 2.25,53.75 1.75,53.75
1.75,53.25 </gml:coordinates>
            </gml:LinearRing>
          </gml:outerBoundaryIs>
        </gml:Polygon>
        </ms:msGeometry>
        <ms:ogc_fid>3</ms:ogc_fid>
        <ms:name>Meu quadrado</ms:name>
        <ms:id>3</ms:id>
      </ms:polygon>
    </gml:featureMember>
</wfs:FeatureCollection>






On Tue, Feb 26, 2008 at 5:34 PM, Andreas Hocevar <andreas.hocevar at gmail.com>
wrote:

> Carlos,
>
> the best way to do what you want is to use OpenLayers.StyleMap. See
> http://trac.openlayers.org/wiki/Styles for a tutorial and
> http://www.openlayers.org/dev/examples/georss-flickr.html for an
> example. You could also use SLD to define your styles. In that case,
> look at http://www.openlayers.org/dev/examples/sld.html for an example.
>
> Things get much easier if you apply
> http://trac.openlayers.org/attachment/ticket/1373/1373-r6361-A0.patch to
> the current trunk version of OpenLayers. This patch also contains an
> example which should do quite exactly what you need.
>
> Regards,
> Andreas.
>
> Carlos Pinto wrote:
> > Your absolutely right, I discover thet only using the version "<script
> > src="http://www.openlayers.org/dev/lib/OpenLayers.js"></script>" could
> > be possible to apply styles to the KML file.
> >
> > So what is the best way to have good style on polygons?
> > GML does not have either and I was trying to avoid customizing one by
> one.
> >
> > I need to draw a grid with ten classes and the simplest way it seemed
> > to have a GML or KML file with all the polygons connected to a style!!!!
> >
> > Thanks for your help
> >
> > Carlos
> >
> >
> >
> > On Tue, Feb 26, 2008 at 5:17 PM, Christopher Schmidt
> > <crschmidt at metacarta.com <mailto:crschmidt at metacarta.com>> wrote:
> >
> >     On Tue, Feb 26, 2008 at 04:13:10PM +0100, Carlos Pinto wrote:
> >     > Hi all,
> >     >
> >     > Can anyone explain why when I run the example:
> >     >
> >     > http://www.openlayers.org/dev/examples/kml-layer.html
> >     >
> >     > it appears a line and 3 polygons with 3 different colors and if
> >     I use
> >     > exactly the same code with the same layer, the polygons are
> >     replaced by one
> >     > line?????
> >     >
> >     > The code is this:
> >     >
> >     >             map.addLayer(new OpenLayers.Layer.GML("KML",
> >     "kml/lines.kml",
> >     >                {
> >     >                 format: OpenLayers.Format.KML,
> >     >                 formatOptions: {
> >     >                   extractStyles: true,
> >     >                   extractAttributes: true
> >     >                 }
> >     >                }));
> >     >
> >     > and in fact, the layer has three polygons with different colors.
> >     What am I
> >     > missing.
> >     >
> >     > I have try also to reference the library that it is online but i
> >     still stay
> >     > with out seeing the polygons.
> >     >
> >     > Can anyone explain this?
> >
> >     What version of OpenLayers are you using? Probably not 2.6;
> >     possibly not
> >     2.5? It sounds like 2.4, though to be honest, there's no polygons
> >     anywhere in this demo, so perhaps I'm confused. In any case, if
> you're
> >     not using a recent trunk, you won't have decent KML styling
> support,,
> >     which it sounds like might be your question.
> >
> >     Regards,
> >     --
> >     Christopher Schmidt
> >     MetaCarta
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Users mailing list
> > Users at openlayers.org
> > http://openlayers.org/mailman/listinfo/users
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080229/79e7e9e5/attachment.html


More information about the Users mailing list