[GIS] Openlayers renderer in IE8 – Labels not visible

labelingopenlayers-2

I copied the source code of http://openlayers.org/dev/examples/vector-features-with-text.html. This url works just fine in IE8.

I put the html page as it is in the webfolder in our network. I opened this page from the local site But what found was labels were not visible in IE but in chrome they seemed just fine.

What should I do to make it work in IE also? WHat is preventing the labels to render in IE but the same code works from the public site above. Ifyou right click and see the code you can see the code as follows:

 renderer = (renderer) ? [renderer] : OpenLayers.Layer.Vector.prototype.renderers;

        var vectorLayer = new OpenLayers.Layer.Vector("Simple Geometry", {
            styleMap: new OpenLayers.StyleMap({'default':{
                strokeColor: "#00FF00",
                strokeOpacity: 1,
                strokeWidth: 3,
                fillColor: "#FF5500",
                fillOpacity: 0.5,
                pointRadius: 6,
                pointerEvents: "visiblePainted",
                // label with \n linebreaks
                label : "name: ${name}\n\nage: ${age}",

                fontColor: "${favColor}",
                fontSize: "12px",
                fontFamily: "Courier New, monospace",
                fontWeight: "bold",
                labelAlign: "${align}",
                labelXOffset: "${xOffset}",
                labelYOffset: "${yOffset}",
                labelOutlineColor: "white",
                labelOutlineWidth: 3
            }}),
            renderers: renderer
        });

Thanks

Vijay

Best Answer

I ran into simmilar problem. It looks it is in VML.js in drawText method:

if(!label.parentNode) {
    label.appendChild(textbox);
    this.textRoot.appendChild(label);
}

the condition is not met and so the label is not appended. I suspect some javascript library interfering. Anyways my dirty solution is to override the method through:

 OpenLayers.Renderer.VML.prototype.drawText = function(){..copied code with the condition removed..}

For the problem doesn't show in the example above, I think it is not OpenLayers bug.