Hongtao's profile微软必应地图(Bing Maps)PhotosBlogLists Tools Help

Blog


    November 24

    必应地图SilverLight控件入门讲座之一:显示地图

    几乎所有的讲座第一讲,是一定要降低难度以鼓励大家快速上手。地图应用的的第一讲莫过于如何显示地图。用必应地图SilverLight控件显示地图似乎比JavaScript更简单。
     
    看图说话吧,没有比这个更简单了。
    1、打开VS2008,创建SilverLight Project
     
    2、选择Host the Silverlight application in a new web site

    3、添加Bing Maps Silverlight Control Reference,通常在必应地图SilverLight地图控件安装目录下,例如:D:\Program Files\Bing Maps Silverlight Control\V1\Libraries

    4、在MainPage.xaml中添加地图命名空间xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"

    5、在<Grid>域中增加地图元素,如下所示:
        <Grid x:Name="LayoutRoot">
            <m:Map/>
        </Grid>
    大功告成,可以显示地图了,编译运行一下吧!是不是比JavaScript还简单Smile
     
    不过由于我们还没有用到Bing Maps Key(参见必应地图SilverLight控件入门讲座之准备工作),所以在操作地图的时候你会发现如下提示:
     
    因此在MainPage,xaml中稍微修改一下:
    <m:Map CredentialsProvider="Your Bing Maps Key" />
     
    好了,第一讲完成了。
     

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks (1)

    The trackback URL for this entry is:
    http://acnchen.spaces.live.com/blog/cns!9321DA57338F36BA!3479.trak
    Weblogs that reference this entry