Reputation: 5220
I've developed a Windows 8.1 app using the blank universal template. The app uses Bing Maps and runs fine when debugging using visual studio.
However, when I package and install the app locally, is fails with the following error:
Exception is about to be caught by JavaScript library code at line 1, column 202459 in ms-appx:///Bing.Maps.JavaScript//js/veapicore.js
0x800a138f - JavaScript runtime error: Unable to get property 'replace' of undefined or null reference
Obviously this is some sort of issue with how I'm using or have referenced the Bing Maps api.
I've including Bing Maps using the following script references in my default.html file:
<script type="text/javascript" src="ms-appx:///Bing.Maps.JavaScript//js/veapicore.js"></script>
<script type="text/javascript" src="ms-appx:///Bing.Maps.JavaScript//js/veapiModules.js"></script>
The exception is happening when I go to initially create the map:
this.map = new Microsoft.Maps.Map(mapElement, mapOptions);
It looks right according to all the documentation I've looked at. Any ideas why it would run fine in the visual studio debugger but fail when packaged and installed? Am I missing something that needs to be included in the package?
Upvotes: 0
Views: 126
Reputation: 5220
Turns out that I needed to call:
Microsoft.Maps.loadModule('Microsoft.Maps.Map' {callback: initMap})
Then initialize the map in the callback. Apparently this isn't required when using Bing Maps AJAX on web pages (the docs I was referencing) but is inside required in a Windows 8.1 javascript app. Not sure why it was ever working without that piece when debugging in Visual Studio.
Upvotes: 0