Anoop Santhanam
Anoop Santhanam

Reputation: 85

Map APIs not working for windows phone in HTML

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 this to my HTML page as a script: http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&mkt=en-gb

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. Basically, this line:

<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&mkt=en-gb"></script> 

should let me run the code I've mentioned above. But, the compiler tells me that "Microsoft" is undefined.

Upvotes: 2

Views: 1057

Answers (2)

Amin
Amin

Reputation: 172

Actually you can add the bing APi for Win8.1 to WP8.1, just hack the bing map APi dll and set the file to Visual Studio and add th bing reference like this

    <!-- Bing Maps references -->
<script type="text/javascript" src="/Bing.Maps.JavaScript/js/veapicore.js"></script>
<script type="text/javascript" src="/Bing.Maps.JavaScript/js/veapiModules.js"></script>

enter image description here

then work normally as you work with Win8.1, see my project. by the way add a code to verify connection status, cause this map work only if the connection exits (if you will add some pushpin manually it can work with no connection)

Fair Of Sfax WP

Upvotes: 1

rbrundritt
rbrundritt

Reputation: 17954

Take a look at this code sample that shows how to use the Bing Maps JavaScript control in WP. http://code.msdn.microsoft.com/Cross-Platform-Bing-Maps-e96600d5

Upvotes: 1

Related Questions