映射API不适用于HTML中的Windows Phone [英] Map APIs not working for windows phone in HTML

查看:177
本文介绍了映射API不适用于HTML中的Windows Phone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近陷入这个奇怪的问题。我更像是一名网络程序员而且我只是冒险开发应用程序。我一直在尝试使用HTML在Windows Phone 8.1上开发这个地图应用程序,我遇到了一个问题。



当我尝试集成Bing地图时,我认为将此作为脚本添加到我的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.

解决方案

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>

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

这篇关于映射API不适用于HTML中的Windows Phone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆