1. Home
  2. Tutorials
  3. Using Native Functionality
  4. Show Directions in the Maps App

Show Directions in the Maps App

directions appmaps app

You can send location data to the maps app on the user device to show directions. For example, if you have a location returned from an API, you can open the maps app to display directions there from the user’s current location, as outlined below.

  1. To access the user location, add a Page Variable of type Core Location - CLLocationManager. Request location access, for example in a Page Loaded Event, using the Request Location Authorization Action, selecting the variable.
  2. Create a Page Variable of type Core Location - CLLocation to store the destination location.
  3. Store the destination location in the CLLocation variable, for example in an API request status code Event. If the location data is in the form of latitude and longitude, use the Create a Location Object Action to store is as a CLLocation. Use a Set Value Action to save the location to the variable you created. location api
  4. Decide when you want to open the maps app for directions, for example when the user taps a button, in which case you would select the button, open Properties > Events, select the Tapped Event, and add an Action.
    • If you’re using the user location, add a Request Location Update Action, selecting the CLLocationManager variable. location update
    • In the nested Location Updated Event, or the Event you’re already working in if you aren’t using the user location, add the Open Maps App for Directions Action. Select a maps app, the start location (from the Event Data if you’re using user location), and the end destination (from the CLLocation page variable). open maps

If you’re using user location, you won’t be able to test the functionality in the web simulator, but you can run it on a physical device. You can show locations on a map inside your app from latitude and longitude – mapping functionality will run in the web simulator as long as the user location is not used.

android mapsgoogle maps

You can send location data to the maps app on the user device to show directions. For example, if you have a location returned from an API, you can open the maps app to display directions there from the user’s current location, as outlined below.

  1. To access the user location, include a Google Maps API Key in your project Location Settings.
  2. Create a Page Variable of type Location - LatLng to store the destination location. latlng var
  3. Decide when you want to open the maps app for directions, for example when the user taps a button, in which case you would select the button, open Properties > Events, select the Tapped Event, and add an Action.
    • If you’re using the user location, add a Request Location Update Action, selecting an accuracy level. location accuracy
    • In the nested Location Updated Event, or the Event you’re already working in if you aren’t using the user location, add the Open Maps App for Directions Action. Select the start location (from the Event Data if you’re using user location), and the end destination (from the LatLng page variable). maps destination

If you’re using user location, you won’t be able to test the functionality in the web simulator, but you can run it on a physical device. You can show locations on a map inside your app from latitude and longitude – mapping functionality will run in the web simulator as long as the user location is not used.

Was this article helpful to you? Yes No

How can we help?