3D Map For Windows 10 UWP

In normal map we have only option to show the map in Satellite or Ariel view but in Windows 10 we have option to show 3D map. It’s very easy to implement 3D map in Universal App.

Now we are going to see how to create a map control to display the map normally and then set the map control to show the map in 3D. Map control with 3D helps the user to view the location at any angle.

Let’s create new Windows 10 Universal Windows app.

First enable the app capabilities “Location” to allow your app to access the location. Open “Package.appxmanifest” file and enable location like the following,

Location

Next go to your MainPage.XAML and add the following xmlns,

  1. xmlns:maps="using:Windows.UI.Xaml.Controls.Maps"  
Add the MapControl using the following xaml code.
  1. <maps:MapControl x:Name="my3dMap" Loaded="my3dMap_Loaded"></maps:MapControl>  
Now go to code behind page and follow the below steps.

Firstly, check the map supports 3D.

Set the map style Aerial3DwithRoads or Aerial3D as you wish. Then set the position latitude and longitude and finally call the TrySetSceneAsync method by passing mapscene.

Here's the complete code,
  1. private async void my3dMap_Loaded(object sender, RoutedEventArgs e)  
  2. {  
  3.     if (my3dMap.Is3DSupported)  
  4.     {  
  5.         my3dMap.Style = MapStyle.Aerial3DWithRoads;  
  6.         BasicGeoposition geoposition = new BasicGeoposition();  
  7.         geoposition.Latitude = 8.4875;  
  8.         geoposition.Longitude = 76.9525;  
  9.         Geopoint location = new Geopoint(geoposition);  
  10.         MapScene mapScene = MapScene.CreateFromLocationAndRadius(location, 500, 150, 70);  
  11.         await my3dMap.TrySetSceneAsync(mapScene);  
  12.     }  
  13. }  
  14. }  
Now run the app and you can see the following output,

output

For Source Code.

Note:

It is showing warning message MapServiceToken not specified, for that we need to get the token from Bing Map Development Center.