1

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="http://www.w3.org/1999/xhtml">
<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>
<style>
 html, body
 {
 width: 100%;
 height: 100%;
 margin: 0;
 padding: 0;
 }
</style>
</head>

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

<system.webServer>
 <httpProtocol>
 <customHeaders>
 <add name="X-UA-Compatible" value="IE=EmulateIE8"/>
 </customHeaders>
 </httpProtocol>
</system.webServer>

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?

Thanks.

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),
 overviewMapControl
 ]
});

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.

asked Apr 30, 2013 at 15:42
4
  • 1
    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. Commented Apr 30, 2013 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. Commented Apr 30, 2013 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. Commented Apr 30, 2013 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. Commented May 1, 2013 at 14:20

1 Answer 1

3

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.

answered May 1, 2013 at 15:10

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.