简体   繁体   English

使用javascript,如何设置通过Silverlight呈现的Bing地图的地图模式?

[英]Using javascript, how can I set map mode of Bing map rendered via Silverlight?

I have googled a lot but have failed to find answer to this problem, Problem: I am loading a Bing map as specified in this MSDN tutorial: Incorporating Map Functionality using Script] 我已经在Google上进行了大量搜索,但是未能找到此问题的答案,问题:我正在按照此MSDN教程中的指定加载Bing地图: 使用脚本合并地图功能]

Now map loads correctly but inside "onSilverlightLoadedHtml" js function, when I try to set its mode using following js statement, it gives me error: map.mode = "aerial" 现在,地图正确加载,但是在“ onSilverlightLoadedHtml” js函数中,当我尝试使用以下js语句设置其模式时,它给了我错误:map.mode =“ aerial”

Error that shows on firebug is following: uncaught exception: Object doesn't support this property or method 在萤火虫上显示的错误如下:未捕获的异常:对象不支持此属性或方法

I have searched a lot but majority resources on Bing map Silverlight are in XAML or using some server side coding. 我已经搜索了很多,但是Bing地图Silverlight上的大多数资源都在XAML中或使用了一些服务器端编码。 But can anybody tell, how can I achieve my goal through javascript ? 但是任何人都可以告诉我,如何通过javascript实现我的目标?

Well....I spoiled my whole day looking for some resolution to my mentioned question, but found nothing and now just after posting it on stackoverflow, I thought to give it an another try and yes....bingo....it worked this time. 好吧...。我整天都在寻找解决我提到的问题的方法,但是却一无所获,现在在将其发布到stackoverflow之后,我想再尝试一下,是的....宾果..这次成功了。 Here is the solution: 解决方法如下:

function onSilverlightLoadedHtml(plugIn, userContext, sender) { 函数onSilverlightLoadedHtml(plugIn,userContext,sender){

var slCtl = document.getElementById(plugIn.id); var slCtl = document.getElementById(plugIn.id);

var mode = slCtl.Content.services.createObject("Microsoft.Maps.MapControl.AerialMode"); var mode = slCtl.Content.services.createObject(“ Microsoft.Maps.MapControl.AerialMode”);

slCtl.Content.map.Mode = mode; slCtl.Content.map.Mode =模式;

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM