Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am serving the following files from a the same directory on localhost:

map.html
OpenLayers.js
output.kml

map.html simply creates an OpenLayers map and displays the KML file as per the OpenLayers example. I access it via http://localhost:8080/map.html and it all works fine in Firefox and Chrome but not in IE. In IE I get the navigation buttons but no map. The OpenLayers example does work in IE...

The contents of map.html are shown below:

<html>
<head>
<title>Map</title>
<script src="OpenLayers.js"></script>
</head>
<body>
<div style="width: 100%; height: 100%" id="map"></div>
<script defer="defer" type="text/javascript">      

var map = new OpenLayers.Map('map');

  <!-- Add background map -->  
    var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
        "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
    map.addLayer(wms);

    <!-- Add kml layer -->  
    var kml = new OpenLayers.Layer.Vector("KML", {
        strategies: [new OpenLayers.Strategy.Fixed()],
        protocol: new OpenLayers.Protocol.HTTP({
            url: "output.kml",
            format: new OpenLayers.Format.KML({
                extractStyles: true, 
                extractAttributes: true,
                maxDepth: 2
            })
        })
    });
    map.addLayer(kml);

    <!-- Zoom -->
    kml.events.register("loadend", kml, function (e) {
    map.zoomToExtent(kml.getDataExtent());
    });

    </script>
</body>
</html>

Any ideas?

share|improve this question

2 Answers 2

I think you might have an error in the javascript code which is only triggered by IE. To better understand what's going on in IE I recommend you install the Developer Toolbar, available as a free add-on from Microsoft:

http://www.microsoft.com/en-us/download/details.aspx?id=18359

IE9 should already have it installed by default.

After installing the IE Developer Toolbar open it by pressing F12 and then look for errors in the javascript console.

Alternatively you can comment out portions of code starting from kml.events.register and see if that fixes it.

Updated after comment

IE chokes because the web server does not return application/xml as the content type. Use the dev toolbar to confirm (inspect network traffic).

To fix configure files with .kml extension as application/xml into your web server configuraion.

share|improve this answer
    
It is the KML Vector layer that breaks IE. It's an unknown Javascript error and from what I have read may be related to IE's same origin policy, even though the KML, HTML and javascript are hosted on the same server. –  user8204 Jun 14 '12 at 14:54
    
I have updated the answer as per your comment –  unicoletti Jun 14 '12 at 18:10
    
I added the mime mapping to jetty but still got the same issue: SCRIPT16389: Unspecified error. OpenLayers.js, line 2589 character 96. –  user8204 Jun 18 '12 at 8:13
    
Could you make the map publicly available so that we can look at at it? –  unicoletti Jun 18 '12 at 10:52

Could this be because of the 'loadend' event? I think it does have issues with IE

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.