[OpenLayers-Users] Label mis-align with IE9

Andreas Hocevar ahocevar at opengeo.org
Tue May 31 10:43:58 EDT 2011


Hi,

On Tue, May 31, 2011 at 4:10 PM, Frank Broniewski <brfr at metrico.lu> wrote:
> Hi Andreas,
>
> I just took
> http://openlayers.org/dev/examples/vector-features-with-text.html and added
> the doctype:
> <!DOCTYPE HTML>
> <html xmlns="http://www.w3.org/1999/xhtml">

This is invalid - a HTML doctype with an xhtml document. I bet this
confuses browsers. Instead, use

<!DOCTYPE html>
<html>

Andreas.

> ...
>
> and in the JS I added a console
> ...
>            renderer = (renderer) ? [renderer] :
> OpenLayers.Layer.Vector.prototype.renderers;
>            console.log(renderer);
> ...
> but I uploaded an example at
>        http://www.gis-hosting.lu/static/tmp/doctype.html
> .
> I'm testing with IE9 32bit Mode on Windows 7 Professional 64bit, if that's
> of any importance.
> All line breaks are removed from the text and the label align of the name:
> toto age: 20 label is still too high in IE9. The line breaks are also in all
> other browsers (Opera, Firefox, Safari and Chrome) missing.
>
>
> Many thanks
>
> Frank
>
>
>
>
> Am 31.05.2011 09:33, schrieb Andreas Hocevar:
>>
>> Hi,
>>
>> the issues you describe sound like there is something weird going on
>> in your application code. If you can provide a simplified example that
>> shows the issue, I'll give it a look.
>>
>> Andreas.
>>
>> On Tue, May 31, 2011 at 9:02 AM, Frank Broniewski<brfr at metrico.lu>  wrote:
>>>
>>> Hi Andreas,
>>>
>>> thanks for your reply. I tried the same example, downloaded the HTML,
>>> added
>>> the HTML5 doctype (<!DOCTYPE HTML>), and tested in IE9. But still, the
>>> name:
>>> toto, age: 20 point label is still not cm - aligned - it's too high. I
>>> logged the renderer and it shows LOG: SVG,VML,Canvas - so I suppose as
>>> SVG
>>> comes first it is used as renderer. And the page concerned had already a
>>> HTML5 doctype ...
>>> Another thing I noticed is that all line breaks are removed from the
>>> labels
>>> when I use the HTML5 doctype, even in the other browsers.
>>> So I fear it is not as simple as adding a doctype.
>>>
>>> Frank
>>>
>>>
>>> Am 30.05.2011 16:26, schrieb Andreas Hocevar:
>>>>
>>>> Playing with
>>>> http://openlayers.org/dev/examples/vector-features-with-text.html,
>>>> it seems that IE 9 does not align labes well in VML, depending on
>>>> doctype and compatibility mode. To make IE9 use the SVG renderer,
>>>> which will fix the issue, you have to use the<!DOCTYPE HTML>    doctype.
>>>>
>>>> Andreas.
>>>>
>>>> On Mon, May 30, 2011 at 3:54 PM, Frank Broniewski<brfr at metrico.lu>
>>>>  wrote:
>>>>>
>>>>> Hi all,
>>>>>
>>>>> I noticed a problem with the label align in IE9. I have a style as
>>>>> follows:
>>>>> var defaultStyle = new OpenLayers.Style(
>>>>>    {
>>>>>        'pointRadius' : '${radius}',
>>>>>        'fillColor' : '#ff8200',
>>>>>        'fillOpacity' : 1,
>>>>>        'strokeColor' : '#fff',
>>>>>        'strokeWidth' : 2,
>>>>>        'cursor' : 'pointer',
>>>>>        'label' : '${label}',
>>>>>        'labelAlign' : 'cm',
>>>>>        'fontColor' : 'white',
>>>>>        'fontFamily' : 'sans-serif',
>>>>>        'fontSize' : '12px',
>>>>>        'fontWeight' : 'bold'
>>>>>
>>>>>    },
>>>>>    {
>>>>>        'context' : {
>>>>>            'radius' : function(feature) {
>>>>>                if (feature.attributes.count>    1) {
>>>>>                    return 8;
>>>>>                } else if (feature.attributes.count == 1) {
>>>>>                    // check for custom num_clients attribute
>>>>>                    if (feature.cluster[0].attributes.num_clients&&
>>>>>                        feature.cluster[0].attributes.num_clients>    1)
>>>>> {
>>>>>                            return 8;
>>>>>                    }
>>>>>                }
>>>>>                return 6;
>>>>>            },
>>>>>            'label' : function(feature) {
>>>>>                if (feature.attributes.count>    1) {
>>>>>                    return feature.attributes.count;
>>>>>                } else if (feature.cluster[0].attributes.num_clients&&
>>>>>                           feature.cluster[0].attributes.num_clients>
>>>>>  1)
>>>>> {
>>>>>                                return
>>>>> feature.cluster[0].attributes.num_clients;
>>>>>                }
>>>>>                return '';
>>>>>            }
>>>>>        }
>>>>>    }
>>>>> );
>>>>>
>>>>> It's a stylemap on a clustered vector layer and the label is misaligned
>>>>> in
>>>>> IE9, it's not in center-middle as it is with firefox or other browsers.
>>>>> Is
>>>>> this a known problem with IE? I suppose this is SVG related, so I
>>>>> really
>>>>> have no clue what I can do. I'm using OL 2.10 ...
>>>>> You can visit http://viaah.lu/adresse/clervaux/clervaux/streets/3/ for
>>>>> an
>>>>> example
>>>>>
>>>>>
>>>>> Many thanks
>>>>>
>>>>> Frank
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Frank BRONIEWSKI
>>>>>
>>>>> METRICO s.à r.l.
>>>>> géomètres
>>>>> technologies d'information géographique
>>>>> rue des Romains 36
>>>>> L-5433 NIEDERDONVEN
>>>>>
>>>>> tél.: +352 26 74 94 - 28
>>>>> fax.: +352 26 74 94 99
>>>>> http://www.metrico.lu
>>>>> _______________________________________________
>>>>> Users mailing list
>>>>> Users at lists.osgeo.org
>>>>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Frank BRONIEWSKI
>>>
>>> METRICO s.à r.l.
>>> géomètres
>>> technologies d'information géographique
>>> rue des Romains 36
>>> L-5433 NIEDERDONVEN
>>>
>>> tél.: +352 26 74 94 - 28
>>> fax.: +352 26 74 94 99
>>> http://www.metrico.lu
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>>>
>>
>>
>>
>
>
> --
> Frank BRONIEWSKI
>
> METRICO s.à r.l.
> géomètres
> technologies d'information géographique
> rue des Romains 36
> L-5433 NIEDERDONVEN
>
> tél.: +352 26 74 94 - 28
> fax.: +352 26 74 94 99
> http://www.metrico.lu
>



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


More information about the Users mailing list