Skip To Content ArcGIS for Developers Sign In Dashboard

ArcGIS Runtime SDK for Qt

Set initial map location

Sample Viewer View Sample on GitHub

Display a basemap centered at an initial location and scale.

Use case

You can set a map's initial location when you want to highlight a particular feature or area to establish the context.

How to use the sample

When the map loads, note the specific location and scale of the initial map view.

How it works

  1. Create a Map, specifying latitude and longitude in WGS84 and target scale.
  2. Display the map in a map view.

Relevant API

  • BasemapType
  • Map
  • MapView

About the data

The map opens with satellite imagery of a guitar-shaped field in the Pampas region of north central Argentina.

Tags

basemap, center, envelope, extent, initial, lat, latitude, level of detail, location, LOD, long, longitude, scale, zoom level

Sample Code

import QtQuick 2.6
import Esri.ArcGISRuntime 100.9

Rectangle {
    width: 800
    height: 600

    // Create MapView that contains a Map with the Imagery with Labels Basemap
    MapView {
        anchors.fill: parent
        Map {
            BasemapImageryWithLabels {}
            // Set the initialViewpoint property to a ViewpointCenter object
            initialViewpoint: viewpoint
        }
    }

    // Create the intial Viewpoint
    ViewpointCenter {
        id: viewpoint
        // Specify the center Point
        center: Point {
            x: -7122777.61840761
            y: -4011076.1090391986
            spatialReference: SpatialReference { wkid: 102100 }
        }
        // Specify the scale
        targetScale: 15000
    }
}