If your app contains a Map Element, you can detect the user long-pressing a location, which you can then present information about. With a Map added to a page in your app:
- Add a new variable in the Page Variables tab on the right of the editor. Give the variable a name and choose CLLocation type.
- Select the Map Element on the Canvas and open Properties > Events. Open the Long Press Event.
- Click the button to add an Action – select Set Value. Click Edit.
- Add another Action, this time choosing Reverse Geocode Location. In the input, select the Page Variable you just updated.
- In the nested Placemark Found Event, add an Action to display the information, for example to include a pin on the map, select the Add Pin to Map Action.
- Select the Map Element in the first input.
- For the Title input, pull a value from the information returned from the Event Data in the Placemark Found Event, such as the placemark name.
- For the subtitle input, do the same as you did for the previous input, but choosing a different value such as the placemark address.
- For the Location input, select the Page Variable.
You can use the Reverse Geocode Location data in other Actions, such as Set Value if you want to display the data in other Elements. To access information about a pin tapped by the user, or to tailor what happens when the user interacts with the pins, use the Map Element Annotation View Selected Event, in which you can retrieve data from the pin via the Event Data container. You can alternatively retrieve information about a location from latitude and longitude.
If your app contains a Map Element, you can detect the user long-pressing a location, which you can then present information about. With a Map added to a page in your app:
- Add a new variable in the Page Variables tab on the right of the editor. Give the variable a name and choose LatLng type.
- Select the Map Element on the Canvas and open Properties > Events. Open the Long Press Event.
- Click the button to add an Action – select Set Value. Click Edit.
- Add another Action, this time choosing Reverse Geocode. In the input, select the Page Variable you just updated.
- In the nested Address Found Event, add an Action to display the information, for example to include a marker on the map, select the Create Marker Action.
- Select the Map Element in the first input.
- For the Title input, pull a value from the information returned from the Event Data in the Address Found Event, such as the first line of the address.
- For the subtitle input, do the same as you did for the previous input, but choosing a different value such as the next line of the address.
- For the Location input, select the Page Variable.
You can use the Reverse Geocode data in other Actions, such as Set Value if you want to display the data in other Elements. To access information about a marker tapped by the user, or to tailor what happens when the user interacts with the markers, use the Map Element Marker Selected Event, in which you can retrieve data from the pin via the Event Data container. You can alternatively retrieve information about a location from latitude and longitude.