IE.txt 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. Using the OpenLayers Javascript from the OpenLayers module can present some
  2. problems with rendering vector layers in IE.
  3. The root cause of the issue:
  4. Internet Explorer has a thing called VML: Vector Markup Language, which it uses
  5. to draw graphics. VML is what you use in IE: canvas4ie is way slow, google maps
  6. uses VML to draw routes, and OpenLayers uses it to draw vectors.
  7. VML elements are styled by creating CSS-like styles in a namespace. OpenLayers
  8. creates an ol: namespace and then creates styles like ol:line ol:circle, etc.
  9. To do this, it has to access document.namespaces. Document.namespaces is not
  10. always around: notably, you can't depend on it being around before
  11. document.ready.
  12. But, sometimes document.namespaces *is* around before document.ready and that's
  13. the thing that messed up my worldview. So, the theory was, there are modes.
  14. Something in HTML can prevent document.namespaces being filled in before
  15. document.ready.
  16. Here's how it goes.
  17. ### $( or $(document).ready()
  18. * If there is a broken image on the page, then namespaces is not filled in.
  19. * If the page has no broken images, then document.namespaces is accessible
  20. ### document.load()
  21. * document.namespaces is always filled in.
  22. ### 31 stylesheets
  23. IE cannot handle more than 31 stylesheets on a page at a time. This is clearly
  24. the devil's work, but it persists beyond IE8. If there are 31 stylesheets and
  25. you run an OpenLayers map, it cannot add another stylesheet to initialize its
  26. VML namespace. Therefore, the map breaks. You must aggregate your CSS.
  27. ### The Fix
  28. We can't move openlayers to document.load() because it is dependent on the
  29. Drupal behaviors stack, that runs on document.ready(). We need to just define
  30. document.namespaces before OpenLayers asks its VML renderer whether the current
  31. browser is capable of rendering VML (a task it tries to complete by calling
  32. !!(document.namespaces))
  33. ### Other Fixes
  34. Adding a tag
  35. <code><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /></code>
  36. will allow IE8 to render vectors if it doesn't render them correctly on a normal
  37. pageload. Note that this must be the first element inside the header tag.
  38. ### Image Opacity
  39. The opacity of image pointers are created with IE filters, which do not function
  40. correctly when combined with semi-transparent PNG images. Thus it is necessary
  41. to set opacity of such elements to 1.0 in order for alpha-transparent PNG images
  42. to appear correctly.