[OpenLayers-Dev] KML Styling

Christopher Schmidt crschmidt at metacarta.com
Mon Oct 15 10:41:00 EDT 2007


On Mon, Oct 15, 2007 at 04:01:22PM +0200, Andreas Hocevar wrote:
> Hi,
> 
> On 10/15/07, Christopher Schmidt <crschmidt at metacarta.com> wrote:
> > On Mon, Oct 15, 2007 at 03:16:43PM +0200, Andreas Hocevar wrote:
> > > On 10/15/07, Christopher Schmidt <crschmidt at metacarta.com> wrote:
> > The 'churn' I'm talking about is converting existing
> > OpenLayers.Feature.Vector.style stuff to use OpenLayers.Style instead.
> > I feel like there is some significant chunk of this in the code still. I
> > could be wrong though, and this will all be a trivial replacement.
> 
> This is definitely something to pay attention to.  I tried to mess
> with existing OL code as little as possible, so I made the new
> OpenLayers.Style co-exist with the existing style hashes.  In fact,
> the good old style hash is still the output of
> OpenLayers.Style.createStyle, which is the only APIMethod of
> OpenLayers.Style.  And the two files ([1] - addFeatures, drawFeature,
> setStyle and [2] - select) where existing code is changed check for
> the CLASS_NAME of the style property.  If it is "OpenLayers.Class",
> then the createStyle() method is used to calculate the style for the
> feature.

Ah, gotcha. Okay, that makes sense -- and also means that there
shouldn't be that much churn, but also that if there are no rules
involved, there's no reason to not have the KML parser return style
objects directly, right? Creating an OpenLayers.Style object is only
useful if you're using rules?  

> > Good feedback. Some of this depends on time, I'm sure. My feeling was
> > just that creating an OpenLayers.Style object should be relatively easy
> > once the KML style *parsing* and so on is done -- converting a
> > {'hash':'of styles'} to an OpenLayers.style object is not much more than
> > a find/replace, I don't think, especially if it's done right in the KML
> > code.
> 
> After thinking twice, I would finally say you're right on that.  The
> OpenLayers.Style class in the ahocevar/sldRenderer sandbox is quite
> simple.  The core of the work was indeed the parser and also the
> rules.  For the parser, things probably are a lot different in KML.

Yep.

> And for the rules, I think there are none in KML.

Yep.

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Dev mailing list