Skip To Content ArcGIS for Developers Sign In Dashboard

Overview

You will learn: how to build a simple app that displays a 2D map.

You can build mapping applications to display geographic data in 2D with AppStudio for ArcGIS. Use the AppStudio QML project template that is pre-configured to display a basemap using the Map QML type. You can either use a basemap that is hosted in ArcGIS Online or create your own basemap with custom styles. If you want to add data to your map, you can add points, lines, polygons as graphics. For larger datasets, you can learn how to add data to feature layers with the Add layers to a map tutorial. Basemaps can be loaded by URL or by using the Basemap QML types. The MapView QML type is responsible for displaying the map and handling user interactions.

In this tutorial, you will build a simple app that displays a topographic vector basemap of the Santa Monica Mountains in California. You will use this tutorial as the starting point for most of the other AppStudio tutorials.

Before you begin

You must have previously installed AppStudio for ArcGIS.

Steps

Create a starter project

  1. Run AppStudio. Click New App. In the New App window, click the Hello World (Runtime) template. Set the Title to Starter app. Click Create.

  2. In the App Gallery, click the Starter app project, and then click {;} Edit. This will open your project in Qt Creator.

  3. In the Qt Creator Projects window, double-click MyApp.qml to open it in the editor.

  4. In the code editor, scroll down to the Map declaration. Update the definition to load the topographic vector basemap and set the map position to the Santa Monica mountains:

        // add a basemap
        Map {
            id:map
            
            // *** UPDATE ***
            //BasemapTopographic{}
            //initialViewpoint: ViewpointCenter {
            //    id:initialViewpoint
            //    center: Point {
            //        x: -11e6
            //        y: 6e6
            //        spatialReference: SpatialReference {wkid: 102100}
            //     }
            //    targetScale: 9e7
            //}
    
            BasemapTopographicVector {}
            initialViewpoint: ViewpointCenter {
                id:initialViewpoint
                center: Point {
                    x: -118.80543                                        // Longitude
                    y: 34.02700                                          // Latitude
                    spatialReference: SpatialReference { wkid: 4326 }    // WGS84
                }
                targetScale: 100000
            }
           
        }
    
  5. In the lower left Sidebar, click Run or press Control-R/Command-R to run the app.

Congratulations, you're done!

Your app should run and display the basemap. Compare your solution with our completed solution project. This project is reused as the starting template for many of the AppStudio tutorials.

Challenge

Explore basemaps

ArcGIS Online hosts a variety of basemaps that you can use in your applications. Construct different basemap types in the Map declaration to display different basemaps. Try setting the basemap to BasemapLightGrayCanvasVector, BasemapDarkGrayCanvasVector, BasemapImagery, BasemapStreetsWithReliefVector, and BasemapNavigationVector.

For example, the code below replaces the topographic vector basemap with BasemapImagery:

      Map {
          id:map
            
          // *** UPDATE ***
          //BasemapTopographicVector {}
          BasemapImagery {}

Change viewpoint

Try different settings for the initial viewpoint by changing the latitude, longitude, and target scale.

Customize your app with AppStudio settings

Select Settings from the AppStudio tool palette to change your app settings. You can change the app icon, launch images, title colors, set native device capabilities, and many other properties to customize your app.