JacobH1994 / google-maps-utility-library-v3

Automatically exported from code.google.com/p/google-maps-utility-library-v3
Apache License 2.0
0 stars 0 forks source link

Error getContext! Map Label Utility Library does not work on IE8 or IE7 #226

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The Map Label Utility Library does not work on IE8 or IE7

I always get the getContext error. 

The labels does not appear.

http://google-maps-utility-library-v3.googlecode.com/svn/trunk/maplabel/examples
/maplabel.html

Original issue reported on code.google.com by sauloben...@gmail.com on 25 Jan 2013 at 11:52

GoogleCodeExporter commented 9 years ago
For any future truth-seekers: IE8 requires the excanvas library extension 
located at: http://code.google.com/p/explorercanvas/

But, as usual for IE-specific stuff, you'll ALSO need to add in special 
IE-specific code to the library itself! I've marked the lines you'll need to 
add with two + signs.

onAdd = function() {
    var canvas = this.canvas_ = document.createElement('canvas');

    if ($.browser.msie) {  //if you're already being nasty all over your code to handle IE nightmares, check for IE directly (example in jQuery)  ++
        canvas = G_vmlCanvasManager.initElement(canvas); //++
    } //++

    if (typeof window.G_vmlCanvasManager != "undefined") { //a friendlier way to check to see if we're in IE emulating Canvas ++
        canvas = G_vmlCanvasManager.initElement(canvas); //++
    } //++

    ...
}

While you're in there, I needed to do this in order to get the textbox to size 
properly:

MapLabel.prototype.drawCanvas_ = function() {
    var canvas = this.canvas_;

    if (!canvas) return;

    canvas.height = this.get('fontSize') + 4;
    canvas.width = this.get('fontSize') * (this.get('text').length);

    ...
}

You'll ALSO need to supply the strokeText function, which can be located: 
http://code.google.com/p/canvas-text/

I'm not going to get into how to supply the text faces, sorry! But this should 
get you started.

Original comment by ChrisBau...@gmail.com on 23 Apr 2013 at 2:39

GoogleCodeExporter commented 9 years ago
Chris,

I have implemented excanvas, and have attempted to implement canvas.text, as 
you suggested.

Right now, this is where I have implemented changes in maplabel-compiled.js:

e[d].onAdd = function () { var a = this.a = document.createElement('canvas'); 
a.style.position = 'absolute'; if (typeof window.G_vmlCanvasManager != 
'undefined') { G_vmlCanvasManager.initElement(a); } var b = a.getContext('2d'); 
b.font = '8px Optimer'; ....This in line 26 of the file provided.

Right now I am receiving no errors in IE8, however my MapLabels are not 
rendering.  Any idea?

Original comment by mora...@gmail.com on 3 Jul 2013 at 3:13