[OpenLayers-Users] GML and KML styleMap

goliah bianchimro at gmail.com
Tue Feb 17 04:45:57 EST 2009


Sorry, the code I posted previously contains a typo, 
the actual code (still not working for KML) is here:


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", filename, {
                        projection: map.displayProjection,
                        styleMap : styleMap,
                        format: OpenLayers.Format.KML,
                       
                        formatOptions: {
                                extractStyles: false,
                                extractAttributes: true
                               
                                               
                        }
                }); 




goliah wrote:
> 
> Dear list,
> 
> 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? 
> 
> 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-tp2339910p2339913.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list