Reverse geocode

View inQMLC++
View on GitHub
Sample viewer app

Use an online service to find the address for a tapped point.

screenshot

Use case

You might use a geocoder to find a customer's delivery address based on the location returned by their device's GPS.

How to use the sample

Tap the map to see the nearest address displayed in a callout.

How it works

  1. Create the Map with a Basemap.
  2. Create a LocatorTask using a URL.
  3. Set the ReverseGeocodeParameters for the LocatorTask and specify the geocode's attributes.
  4. Get the matching results from the GeocodeResult using ReverseGeocodeWithParameters
  5. Change the attributes of the MapView's CalloutData and display the location using a Callout

Relevant API

  • GeocodeParameters
  • LocatorTask
  • ReverseGeocodeParameters

Offline data

Read more about how to set up the sample's offline data here.

Link Local Location
pin PNG file <userhome>/ArcGIS/Runtime/Data/symbol/pin.png

About the data

This sample uses the World Geocoding Service.

Tags

address, geocode, locate, reverse geocode, search

Sample Code

ReverseGeocodeOnline.qmlReverseGeocodeOnline.cppReverseGeocodeOnline.h
                                           
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// [WriteFile Name=ReverseGeocodeOnline, Category=Search]
// [Legal]
// Copyright 2020 Esri.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// [Legal]

import QtQuick 2.6
import QtQuick.Controls 2.2
import Esri.Samples 1.0
import Esri.ArcGISRuntime.Toolkit 100.12

Item {

    // add a MapView component
    MapView {
        id: view
        anchors.fill: parent

        Callout {
            id: callout
            calloutData: view.calloutData
            accessoryButtonHidden: true
            leaderPosition: leaderPositionEnum.Top
            padding: 5
        }
    }

    // Declare the C++ instance which creates the scene etc. and supply the view
    ReverseGeocodeOnlineSample {
        id: model
        mapView: view
    }
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.