Placemark name from KML to OpenLayers Label.
        Posted  
        
            by Ozaki
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Ozaki
        
        
        
        Published on 2010-06-10T03:21:07Z
        Indexed on 
            2010/06/10
            4:52 UTC
        
        
        Read the original article
        Hit count: 1175
        
TLDR I have a KML layer in OpenLayers. It pulls out the geometries images placemarks etc. But will not apply a label to any of my placemarks etc:
I am stumped by this one my StyleMap is as follows:
           var styleMap = new OpenLayers.StyleMap({
                fillOpacity: 1,
                pointRadius: 10,
                label: "${name}", //I believe this should pull the name attr from the KML
                fontColor: "#7E3C1C",
                fontSize: "13px",
                fontFamily: "Courier New, monospace",
                fontWeight: "strong",
                labelXOffset: "0",
                labelYOffset: "-15"
            });
and the layer:
                var mykmllayer= new OpenLayers.Layer.Vector("KML Layer", {
                styleMap: styleMap,
                    projection: new OpenLayers.Projection("EPSG:4326"),
                    strategies: [new OpenLayers.Strategy.Fixed()],
                    protocol: new OpenLayers.Protocol.HTTP({
                        url: URLTOKML,
                        format: new OpenLayers.Format.KML({
                        styleMap: myStyles,
                            extractStyles: true,
                            extractAttributes: true
                        })
                    })
                });
(Insert shameless bump here)bump
Does anyone know maybe what I am missing or a reason why this wouldn't work?
© Stack Overflow or respective owner