[OpenLayers-Users] GML and KML styleMap

Andreas Hocevar ahocevar at opengeo.org
Tue Feb 17 05:53:12 EST 2009


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.

Regards,
Andreas.

>
> Thanks a lot
> Mauro
>
>
>
>
> var symbolizer = OpenLayers.Util.applyDefaults(
>        {fillColor:'red', fillOpacity: 0.4, strokeColor: "black"},
>        OpenLayers.Feature.Vector.style["default"]);
> styleMap = new OpenLayers.StyleMap({"default": symbolizer});
>
> if(layertype == 'gml')
>                overlay = new OpenLayers.Layer.GML("GML", filename, {extractAttributes:
> true, styleMap: styleMap});
>
> else if(layertype == 'kml')
>                overlay = new OpenLayers.Layer.GML("GML", opts['layer'], {
>                        projection: map.displayProjection,
>                        styleMap : styleMap,
>                        format: OpenLayers.Format.KML,
>
>                        formatOptions: {
>                                extractStyles: false,
>                                extractAttributes: true
>
>
>                        }
>                });
>
> --
> View this message in context: http://n2.nabble.com/GML-and-KML-styleMap-tp2339910p2339910.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.



More information about the Users mailing list