[Q] Map APIs not working for windows phone in HTML

Search This thread

BinoxMe

New member
Jun 8, 2014
1
0
Ran into this strange issue recently. I'm more of a web programmer and I've only just ventured into developing apps. I've been trying to develop this mapping app on windows phone 8.1 using HTML and I came across a problem.

When I try to integrate Bing maps, I'm supposed to add the URL at virtualearth to my HTML page as a script.

Now, when I try to initialize my map using

if (Microsoft.Maps.ClientRegion) {
Microsoft.Maps.loadModule('Microsoft.Maps.Map', { callback: getMap });
} else {
getMap();
}

Visual Studio breaks the execution and tells me that 'Microsoft' is undefined. It doesn't make sense since this code works perfectly in a browser. I tried linking to another script file on my server and called a random function to display "hello world" and it worked. So, That clearly implies that the app has no problem referring to external scripts.

I gave up on Bing and tried to deploy Google maps in my app. Same thing except now it says, "google" is undefined.

I have no idea what's happening here. Any sort of help is appreciated! Fyi, I've also called init() once the document loads.

Thanks in advance!

Edit: To be clear, this isn't a web app running through a browser. There is an option for me to code in HTML in Visual Studio and it worked fine until this showed up. I've also partly developed a Windows 8 Desktop app using HTML and using Bing Maps to integrate mapping functionalities and it works great.

What I don't understand is how the code for the mobile app works great through a browser, works great on windows store apps, but doesn't work at all when coded directly through Visual Studio. I am pretty sure I've missed something. I hope someone can figure this out.
 

gradyzero

Member
Oct 9, 2011
30
5
Atlanta
Just curious does it work in the WP8 1 emulator on you work station? I have a friend who has similar problems but his conclusions are that the emulator is just that and the phone APIs aren't exactly the same in the phone. He is working in C## but the behavior sound similar. BTW, what version of Visual Studio are you using? If it is an Express version like 2013, I would consider going back to 2010. Hope this helps.


Sent from my RM-893_nam_tmous_201 using XDA Windows Phone 7 App
 

gradyzero

Member
Oct 9, 2011
30
5
Atlanta
One other issue that occur to me this morning. Did you register the maps at the Bing map site. Your code snippet does not show you using your unique app ID to call the map API. You must have a unique app ID assigned to you. It's not done by just registering your VS 2013 with your Microsoft account. Grady, XTC Media Group, LLC.

Sent from my RM-893_nam_tmous_201 using XDA Windows Phone 7 App

---------- Post added at 11:36 AM ---------- Previous post was at 11:28 AM ----------

BTW, I was wrong to recommend 2010. You must use 2013 with Service pack 2 applied. Also is your hyper-v configured and working properly? The Visual Studio Phone emulator runs in hyper-v. So you need Windows 8 or 8 1 with hyper-v to test with the emulator. You never answered my question about whether the app runs in the 8.1. Phone emulator

Sent from my RM-893_nam_tmous_201 using XDA Windows Phone 7 App