Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
Bing Map displaying Shapefieles
Hi everybody,

sorry for my bad English!

I have a question?
is there a simple way with Bing Map displaying Shapefieles so that the shapes are geocoded correctly?

I've loaded the example already in men's, but it can not emulate the Bing, the API has changed.

Many thanks


this is my original bing:
    d:DesignHeight="300" d:DesignWidth="400">
        <Grid x:Name="LayoutRoot" Background="White" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
     <m:Map  CredentialsProvider="x" x:Name="MyMap" Grid.Row="1" Mode="Road" Center="51.36236,7.47651" ZoomLevel="11" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />

this is the attempt to unite it:

    d:DesignHeight="300" d:DesignWidth="400">
        <Grid x:Name="LayoutRoot" Background="White" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <m:Map  CredentialsProvider="x" x:Name="MyMap" Grid.Row="1" Mode="Road" Center="51.36236,7.47651" ZoomLevel="11" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
             <SolidColorBrush Color="Transparent" Opacity="0"/>
         FillMode="Choropleth" FontSize="2.5">
            <igMap:ShapeFileReader DataMapping="Name=PLZ" Uri="shp/ZipCode" />
   <igMap:MapNavigationPane Margin="10" igControls:XamDock.Edge="InsideRight" />




  • 4666
    Verified Answer

    Hi Olaf,

    Probably you want to display data from BingMaps using data from BingMaps and shape files:

    I will give you a sample:

    1. You need to have a token from BingMaps:

    From Bing Maps Account Center :

    you need to generate a Bink Maps key (token) for your account to use with your application.

    2. Add a token in your Web.config file:

      <add key="token" value=[my application token]/>

    3. In the web project modify the default page :

    In Default.aspx.cs

           public string InitParams { get; set; }


           protected void Page_Load(object sender, EventArgs e)



                if (System.Configuration.ConfigurationManager.AppSettings.Count > 0)


                    string customSetting =


                    if (customSetting != null)


                        InitParams = "clientToken=" + customSetting;





    In Default.aspx:

        <div id="silverlightControlHost">

            <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">

              <param name="source" value="ClientBin/SlSQLSpatialApp.xap"/>

              <param name="onError" value="onSilverlightError" />

              <param name="background" value="white" />

              <param name="initParams" value="<%=InitParams%>" />

              <param name="minRuntimeVersion" value="4.0.50401.0" />

              <param name="autoUpgrade" value="true" />

              <a href="" style="text-decoration:none">

                  <img src="" alt="Get Microsoft Silverlight" style="border-style:none"/>


            </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe>


    In your client application:

    In App.xaml.cs:

           private void Application_Startup(object sender, StartupEventArgs e)


                _token = e.InitParams["clientToken"];

                Application.Current.Resources.Add("token", _token);

                this.RootVisual = new MainPage();


    You need this key to access the Bing Maps service

    Add a reference to BingMaps inagery service:

    In the Silverlight application startup page you have no neet do add anything for this. In my sample I just added a combobox where to select witch maps style to load from Bing Maps service.

    MapControl has defined readers on for a vector data (shape files) there:



                            Name="World" Brushes="#4C2C42C0 #4C218B93 #4CDC1C1C #4C3D7835 #4C701B51"

                            FillMode="Choropleth" WorldRect="{Binding ElementName=MainWindow, Path=WorldRect}"                       



                                <ig:ShapeFileReader Uri="ShapeFiles\Cntry00\Cntry00"

                                       DataMapping="Name=CNTRY_NAME; Value=POP_CNTRY; Caption=CNTRY_NAME; ToolTip=CNTRY_NAME" />



                            <ig:LinearScale IsAutoRange="True"/>




    in the cs file you need to add code to load a data from Bing Maps:

            private void SetImagerySource()


                ComboBox combo = this.FindName("xMapStyle") as ComboBox;


                if (combo != null)


                    if (combo.SelectedIndex == -1)


                        combo.SelectedIndex = 2;


                    MapStyle mapStyle = (MapStyle)combo.SelectedItem;

                    if (mapStyle == MapStyle.Birdseye || mapStyle == MapStyle.BirdseyeWithLabels)


                        MessageBox.Show("You can't use Birdseye and BirdseyeWithLabels Map Styles");

                        combo.SelectedIndex = -1;






            private void GetImagerySource(MapStyle mapStyle)


                ImageryMetadataRequest metadataRequest = new ImageryMetadataRequest();


                // Set credentials using a valid Bing Maps Key

                metadataRequest.Credentials = new Credentials();

                metadataRequest.Credentials.ApplicationId = _key;



                metadataRequest.Style = mapStyle;


                // Make the imagery metadata request

                ImageryServiceClient imageryService = new ImageryServiceClient();


                imageryService.GetImageryMetadataCompleted -= ImageryServiceGetImageryMetadataCompleted;

                imageryService.GetImageryMetadataCompleted += new EventHandler<BingMapsImageryService.GetImageryMetadataCompletedEventArgs>(ImageryServiceGetImageryMetadataCompleted);


            void ImageryServiceGetImageryMetadataCompleted(object sender, GetImageryMetadataCompletedEventArgs e)


                this.xamMap.MapTileSource = new BingMapsTileSource


                    Token = _key,

                    TilePath = e.Result.Results[0].ImageUri,

                    SubDomains = e.Result.Results[0].ImageUriSubdomains




    Hope this can help :-)