Develop your first map app

At the heart of most ArcGIS Runtime SDK apps are the MapView control and its associated Map. These components allow you to easily add a map to your app with a few lines of code. See the Maps topic for more information about maps and map views.

This tutorial guides you along the shortest path possible to get a mapping app up and running with ArcGIS Runtime SDK for .NET. It assumes that you have installed the ArcGIS Runtime SDK Visual Studio Extension as described in the Install the SDK topic.

Prerequisites

This tutorial requires a supported version of Microsoft Visual Studio and the ArcGIS Runtime SDK for .NET Visual Studio Extension. Refer to the appropriate topics in the guide to see if your machine meets the system requirements or if you need help installing the SDK.

No familiarity with Visual Studio or .NET programming is required to complete this tutorial.

Create a WPF app

Use Visual Studio to create a WPF app.

  1. Open a supported version of Microsoft Visual Studio.
  2. Choose File > New > Project (or click New Project on the Start page) to create a project.
  3. Click Windows > Classic Desktop in the New Project dialog box template list. Choose the ArcGIS Runtime Application (WPF) template.
    Creating your project from the template adds the appropriate references and a page with a map view containing a single base layer.
  4. Choose a folder location for your new project and name it MyFirstMapApp.

    Visual Studio New Project dialog

  5. Click OK to create the project.

    The ArcGIS Runtime App template references the ArcGIS Runtime API for .NET NuGet package. When you first build the project, the required NuGet package (or packages) will be restored in the project. You can also restore them manually using the NuGet Package Manager.

    Your solution opens in Visual Studio and contains a WPF window called MainWindow.xaml. This file defines the UI for the app with a MapView control to display a Map.

    The following XAML is created by the template to display a map in the map view using data binding.

    <Grid>
        <esri:MapView Map="{Binding Map, Source={StaticResource MapViewModel}}" />
    </Grid>

    The MapViewModel class contains the logic to create a Map and expose it as a public property for consumption in the UI (MapView). This is a simple example of the MVVM pattern that's used to separate business logic in your app from the user interface tier.

  6. Click the Start button on the Standard toolbar (or Debug > Start Debugging) to start your app. You'll see a map similar to the following:

    World streets (vector) basemap

    By default, the map displays at the full extent of the first (bottom) layer it contains. To show the initial view of the map at a particular location, you can add logic to define a specific extent when the app starts.

    In MapViewModel, the code that creates the Map defines a basemap using Basemap.CreateStreetsVector. There are several static helper methods like this on Basemap that can be used to create predefined basemaps for use with your Map. If you feel like experimenting, try changing the basemap using one of the following static methods on Basemap.

    • CreateDarkGrayCanvasVector
    • CreateImagery
    • CreateImageryWithLabels
    • CreateImageryWithLabelsVector
    • CreateLightGrayCanvas
    • CreateLightGrayCanvasVector
    • CreateNationalGeographic
    • CreateNavigationVector
    • CreateOceans
    • CreateStreets
    • CreateStreetsNightVector
    • CreateStreetsVector
    • CreateStreetsWithReliefVector
    • CreateTerrainWithLabels
    • CreateTerrainWithLabelsVector
    • CreateTopographic
    • CreateTopographicVector

    Note:

    The method names ending in Vector use vector tile basemaps. Otherwise, the basemaps are based on raster tiles.

That's it. You created a simple map app without writing a single line of code. As a next step, consider exploring the functionality provided by ArcGIS Runtime SDK for .NET by examining the many samples provided with the SDK.

Related topics