Find the location for an address or find the address of a selected location using the Geocoding service.
How to use the sample
This sample demonstrates the capability of the Geocoding service inside Unity. You can perform two kinds of operations with this sample, find a place and find an address.
- Open the Geocoding scene.
- Click on the ArcGISMap game object in the Hierarchy window.
- Set your API key in the Inspector window.
- Click play.
- Use the search bar to find a place by name or address. For information about the type of locations supported by the Geocoding service, see the ArcGIS REST APIs documentation.
- To find a place's address, drop the marker on your point of interest by clicking in the viewport while holding Shift. The address will be displayed above the marker.
Note: This sample is only set up to work with a mouse and a keyboard.
How it works
- Have an ArcGIS Map with the mesh colliders enabled in the scene
- Create a child game object under the ArcGIS Map and attach the geocoding script.
- The HTTPClient is used to query the Geocoding service.
- The
findAddressCandidates
operation is used for finding a place. - The
reverseGeocode
operation is used for finding an address. The marker should have the ArcGIS Location component attached and its values will be used to query the address of the location. - Place a marker using the Location Components Surface Placement mode set to
OnTheGround
for elevation at the queried position.
Tags
geocoding, reverse geocoding, address, locate, search