Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So, I'm writing an web mapping application using OpenLayers in WebForms in .NET 4.5.

It was working wonderfully until my browser upgraded to IE9. Now the JavaScript fails. After researching I found that the problem seems to be that IE9 changed how it handles certain kinds of JavaScript. So the solution, until the community can rewrite the JavaScript libraries, seems to be to have the browser run in compatibility mode. Unfortunately, I can't seem to get compatibility mode to work correctly.

Currently my application has one page and this is the header:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="AgPlaceHolder._default" %>

<!DOCTYPE html>

<html xmlns="">
<head runat="server">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<title>Agrilogic Place Holder</title>
<script src="OpenLayers.js"></script>
<script src="AgInit.js"></script>
<script src="AgLabels.js"></script>

    html, body
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;

It didn't work. So I found this alternative to add to the web.config file:

      <add name="X-UA-Compatible" value="IE=EmulateIE8"/>

This also didn't work.

I've tried some variations I've seen used around, but none of them seem to be working. Does anyone see what I might have done wrong? Or has another solution to this problem?


On Edit:

I'm using OpenLayers 2.12.

The error is:

Unhandled exception at line 670, column 407 in http://localhost:57639/OpenLayers.js

0x800a138f - Microsoft JScript runtime error: Unable to get value of the property 'resources': object is null or undefined

The code for setting up the map is:

map = new OpenLayers.Map({
    div: "map",
    layers: layerArray,
    controls: [
        new OpenLayers.Control.LayerSwitcher({ roundedCorner: true }),
        new OpenLayers.Control.PanZoomBar(),
        new OpenLayers.Control.Navigation(),
        new OpenLayers.Control.ScaleLine({ geodesic: true }),
        new OpenLayers.Control.KeyboardDefaults(),
        new OpenLayers.Control.MousePosition({
            displayProjection: new OpenLayers.Projection("EPSG:4326"),
            numDigits: 5,
            emptyString: '',
            prefix: "x: ",
            separator: " y: "
        //new OpenLayers.Control.EditingToolbar(editableLayer),
        //new OpenLayers.Control.SelectFeature(editableLayer, { toggle: true, clickout: true }),
        //new OpenLayers.Control.DragFeature(editableLayer),

The java script works fine, except for another issue I have posted a question on over in GISStackExchange, but that's not preventing the maps from showing. The problem there is I can't drag the label-points the program creates. But now with the upgrade of the browser I can't even display the maps anymore. The page just fails.

The newly built page has the same errors. When I remove Bing:

0x800a138f - Microsoft JScript runtime error: Unable to get value of the property 'wrapDateLine': object is null or undefined

When I include Bing:

0x800a138f - Microsoft JScript runtime error: Unable to get value of the property 'resources': object is null or undefined

I am at the mercy of your expertise.

share|improve this question
JavaScript fails? What is failing? Are you seeing nothing, are you seeing errors? Your question doesn't tell us what the actual problem is. Also, I know that OpenLayers definitely does work in IE9. What version of OpenLayers are you using? Please also give us some more details and show us how you are currently setting up the map. – René Wolferink Apr 30 '13 at 15:55
I stripped the code all the way to just displaying a Bing Layer. It still failed. I'm going to create a new project and see if that fixes it. – bshender Apr 30 '13 at 20:09
I think it's most likely you're passing a bad argument, or missing one altogether, when initialising the map or other OpenLayers components. How is overviewMapControl defined? You might want to use the uncompressed version of the OL library and debug around the line that throws your error. Follow the call stack back up until you find a line of your own code, then inspect what you're passing with it. – tomfumb Apr 30 '13 at 22:08
When I run the script in Apache it works just fine. When I copy the script into Visual Studio it fails. When I've done this before I didn't have any problems. I went ahead I tried to run it on someone else's machine here and it also failed. It's defined this way: var overviewMapControl = new OpenLayers.Control.OverviewMap({ options: { layers: layerArray, maxRatio: .33 } }); I needed to separate it out so I could redefine it when the base layer changed. The control doesn't handle third party base layers like BING very well. – bshender May 1 '13 at 14:20
up vote 2 down vote accepted

So, apparently BING sends its "your key is expired" error message under status 200. OpenLayers, quite reasonably, assumed that status 200 meant "O.K." when BING meant "we're too lazy to do this correctly." Naturally, Chrome Developer Tools, FireBug, and Visual Studio did the same thing and reported no problem and until the script tried to run. So note to the next guy: open the entire response, don't believe the header.

share|improve this answer

Your Answer


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.