OpenLayers: Does not work in internet explorer

痞子三分冷 提交于 2019-12-12 12:36:01

问题


I have this simple code:

<HTML>
<head>
<title>Vector Icon Example</title>
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
<link rel="stylesheet" href="../apidoc/styles/bootstrap.min.css">
<script src="../apidoc/scripts/bootstrap.min.js"></script>
    <link rel="stylesheet" href="../css/ol.css" type="text/css">
<script src="../build/ol.js"></script>


</head>
<BODY>
<div id="map" style="width: 100%, height: 400px">ggg</div>
<script>
  new ol.Map({
    layers: [
      new ol.layer.Tile({source: new ol.source.OSM()})
    ],
    view: new ol.View({
      center: [0, 0],
      zoom: 2
    }),
    target: 'map'
  });
</script>
</BODY>
</HTML>

It works correctly in chrome, but in IE 11 does not appear anything. where is the problem?


回答1:


This solved my problem:

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">



回答2:


new OpenLayers.Layer.OSM()

does't work for me on IE11 as well.

I tried with https scheme since there was changes with redirecting from http to https for openstreetmap tiles:

new OpenLayers.Layer.OSM({
            name: "OpenStreetMap",
            url: ["https://a.tile.openstreetmap.org/${z}/${x}/${y}.png",
                "https://b.tile.openstreetmap.org/${z}/${x}/${y}.png",
                "https://c.tile.openstreetmap.org/${z}/${x}/${y}.png"],
            tileOptions: {crossOriginKeyword: null},
            crossOrigin: null
        });

Still not rendered from my local in IE11. Also provided metatag doesn't help...

Another one works fine (but I need X.tile.openstreetmap.org for rendering):

 new OpenLayers.Layer.OSM("OpenCycleMap",
                   ["http://a.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png",
                    "http://b.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png",
            "http://c.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png"]);



回答3:


This worked for me:

new OpenLayers.Layer.OSM("OpenStreetMap", ["https://a.tile.openstreetmap.org/${z}/${x}/${y}.png", "https://b.tile.openstreetmap.org/${z}/${x}/${y}.png", "https://c.tile.openstreetmap.org/${z}/${x}/${y}.png"]);



来源:https://stackoverflow.com/questions/32691676/openlayers-does-not-work-in-internet-explorer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!