If you haven't already, sign up for Radar to get your API key. You can create up to 1,000 geofences and make up to 100,000 API requests per month for free.Get API Keys
On the Geofences page, import geofences for each store.
The CSV should include 8 columns:
description: A display name for the geofence. In this case, the store name.
tag: A group for the geofence. In this case,
externalId: An external ID for the geofence that maps to your internal database. In this case, the store ID.
type: The type of geofence geometry. In this case,
radius: The radius in meters for type circle. In this case,
coordinates: A JSON string representing a center in the format [longitude,latitude] for type circle. Note that longitude comes before latitude, a GeoJSON convention.
enabled: In this case,
metadata: A set of custom key-value pairs for the geofence. A JSON string representing a dictionary with up to 16 keys and values of type string, boolean, or number. In this case,
If you're starting from scratch, create a new Xcode project of type Single View App.
Initialize the SDK in your
AppDelegate class with your publishable API key.
MapKit and add a
UISearchBar (for the address input) and
MKMapView (for the map) to your
Make your search bar a
UISearchBarDelegate. Connect the search bar and map to the
ViewController and set the
ViewController as the
delegate for the search bar.
Alternatively, we could display the results in a
searchBarSearchButtonClicked: method of the
UISearchBarDelegate to call the forward geocode API when a user enters an address into the search bar, then move the map to the coordinate of the address.
Alternatively, we could call the autocomplete API to autocomplete partial addresses as the user types.
Finally, pass the coordinate to the geofence search API to retrieve stores, convert the stores to map annotations, and add the annotations to the map.
In this case, we pass
radius: 10000 to retrieve stores within 10 kilometers,
tag: "store" to retrieve only geofences with tag store, and
limit: 10 to retrieve up to 10 stores at a time. Optionally, we could pass
metadata: ["parking": true] to retrieve only stores with parking.
Alternatively, we could call the place search API retrieve places from Radar's place database, rather than custom geofences.
Have questions or feedback on this documentation? Let us know! Email us at [email protected].