[OpenLayers-Users] GML and KML styleMap

Mauro Bianchi bianchimro at gmail.com
Tue Feb 17 08:37:32 EST 2009


Yes,
I am using v. 2.7 but it's  like the extractStyles attribute  behaves
correctly.

I've come to the real problem in my code: it seems like feature attributes
are not loaded from the KML file (and extractAttributes is set to true).
(I'm debugging with firebug)
This causes visualization problem as I set a "loadend" event which modifies
the styleMap adding a rule based on one of the attributes. This works
perfectly with the GML format.

here is an excerpt of my KML file (with only 1 feature in this case):



<?xml version="1.0" encoding="utf-8" ?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document><Folder><name>CALOPICOS</name>
<Schema name="CALOPICOS" id="CALOPICOS">
    <SimpleField name="Name" type="string"></SimpleField>
    <SimpleField name="Description" type="string"></SimpleField>
    <SimpleField name="COD_PRO" type="int"></SimpleField>
    <SimpleField name="NOME" type="string"></SimpleField>
    <SimpleField name="NOME_PRO" type="string"></SimpleField>
    <SimpleField name="SIGLA_PRO" type="string"></SimpleField>
    <SimpleField name="COD_ISTAT" type="float"></SimpleField>
</Schema>
  <Placemark>
    <ExtendedData><SchemaData schemaUrl="#CALOPICOS">
        <SimpleData name="COD_PRO">16</SimpleData>
        <SimpleData name="NOME">COSTA VOLPINO</SimpleData>
        <SimpleData name="NOME_PRO">BERGAMO</SimpleData>
        <SimpleData name="SIGLA_PRO">BG</SimpleData>
        <SimpleData name="COD_ISTAT">16086</SimpleData>
    </SchemaData></ExtendedData>

<Polygon><outerBoundaryIs><LinearRing><coordinates>10.085200473748921,45.822892231012993,0
10.084585250268859,45.824369844126821,0
10.082453051210173,45.825119119054406,0
10.081007598805416,45.82684743097554,0
10.079839599744659,45.828613605040289,0
10.07717727161147,45.830258855140812,0
10.075010482295186,45.832070393590513,0
10.074058365470743,45.834532025789372,0
10.073265850979176,45.837262169208579,0
10.06965146883106,45.839991757279705,0
10.069422672793097,45.842248559262387,0
10.064130839354922,45.846186242510463,0
10.063978762676339,45.846484679629334,0
10.06434346681317,45.847880880744242,0
10.065628096568989,45.849984053949292,0
10.06583877006006,45.852668775022906,0
10.059618008333993,45.853626698390897,0
10.060379779795703,45.8545691964189,0
10.061666817265563,45.856798398052135,0
10.062159359739915,45.86042556732729,0
10.062166458357162,45.861136549440864,0
10.062491195614504,45.862798642438662,0
10.065108076125764,45.864151370298352,0
10.068276042583895,45.865093859662544,0
10.072075944094292,45.865310285186304,0
10.076297156735873,45.86666119250448,0
10.079277324783051,45.868118179615614,0
10.081854931270923,45.869902922584458,0
10.083140114771034,45.871807873298508,0
10.083937880830906,45.874153962689711,0
10.090736923776577,45.868904916714143,0
10.098095854836334,45.859113773118835,0
10.100973987278632,45.857677479099273,0
10.102589304925999,45.857121865281528,0
10.104952026382794,45.857639077088834,0
10.10549408372342,45.855091158649536,0
10.105693309684447,45.854094662090652,0
10.1137341462167,45.847482107958633,0 10.114255005756153,45.84534837924182,0
10.116027434531851,45.844462518344471,0
10.122735862283923,45.836476225598282,0
10.121797095471102,45.835576381034869,0
10.120717567718057,45.834317883315961,0
10.120381475009312,45.833691133795753,0
10.119058597198419,45.83249351040147,0
10.11877669773189,45.831276682048355,0
10.118713269859052,45.831002783035999,0
10.119842908081528,45.829790128259653,0
10.120160355091627,45.828927453139038,0
10.119746843183558,45.828530977131464,0
10.119565205620738,45.827097151264411,0
10.117436113711921,45.826937981496528,0
10.114963648834435,45.825459025574261,0
10.115432920583952,45.823735317328207,0
10.114350889127907,45.822251764759208,0
10.112532429508482,45.820712370359843,0
10.111123144812886,45.819110463619964,0
10.109297908149857,45.817058044204309,0
10.108380256032628,45.815572837402364,0
10.107786712642209,45.813796458819702,0
10.105413813519233,45.813810441626721,0
10.103850765681402,45.812956988036674,0
10.101945727268799,45.811076233310892,0
10.101763303405559,45.809412865143194,0
10.098657051624869,45.808088648873721,0
10.097241706756741,45.807485228316132,0
10.093045867937683,45.805500291707737,0
10.090559449954725,45.804542976919514,0
10.088601629641808,45.807842401601263,0
10.085108910653183,45.816286768196576,0
10.085674454851302,45.822370351516362,0
10.085264836458663,45.822738770296141,0
10.085200473748921,45.822892231012993,0</coordinates></LinearRing></outerBoundaryIs></Polygon>
      <Style><LineStyle><color>ff0000ff</color></LineStyle>
<PolyStyle><fill>1</fill></PolyStyle></Style>
  </Placemark>

</Folder></Document></kml>


2009/2/17 Christopher Schmidt <crschmidt at metacarta.com>

> On Tue, Feb 17, 2009 at 11:53:12AM +0100, Andreas Hocevar wrote:
> > On Tue, Feb 17, 2009 at 10:44 AM, goliah <bianchimro at gmail.com> wrote:
> > > I'm trying to load a layer from a local file, using a GML or KML format
> > > based on file extension, and applying the same styleMap in both cases.
> > > The following code only works for GML but not for KML format.
> > > The var filename is the file to load and the var layertype is the
> extension
> > > of the file.
> > >
> > > Any hint?
> >
> > Without knowing your KML data, my guess would be that the KML has
> > inline styles, which would override your styleMap.
>
> Assuming you're using 2.7 though, this shouldn't be an issue with
> extractStyles false:
>
>  http://trac.openlayers.org/ticket/1576
>
> So if this is the case, then we should probably look into it and fix it.
>
> Goliah, are you using 2.7? Does this seem like it is possibly the case?
>
> Regards,
> --
> Christopher Schmidt
> MetaCarta
>



-- 
Mauro Bianchi
bianchimro at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090217/e9f588c8/attachment.html


More information about the Users mailing list