🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Geolocation
This page was created by Henrik on 2018-01-28. Last edited by Wikiadmin on 2026-07-29.

You can capture the browser-provided current latitude and longitude in a MDriven Web application by adding two correctly named string variables to a ViewModel.

Configure geolocation

MDriven recognizes the following ViewModel variable names for the HTML5 geolocation API. When the browser permits location access, it assigns the current location to these variables.

ViewModel variable Type Value supplied by the browser
vClientLatitude String The current latitude
vClientLongitude String The current longitude
  1. Open the ViewModel that needs the user's location.
  2. Add a variable named vClientLatitude and set its type to String.
  3. Add a variable named vClientLongitude and set its type to String.
  4. Keep the names exactly as shown, including capitalization.
  5. Run the application in a browser and allow the browser's location-permission request.
  6. Use the two variables in the ViewModel where your application needs the captured coordinates.

Example

A delivery ViewModel can contain vClientLatitude and vClientLongitude. When a user opens the application and permits location access, the browser writes the user's current coordinate values into those variables. Your ViewModel can then use the values as input for its delivery-location logic.

Permission behavior

Location access is controlled by the browser. The browser assigns values only when permission is granted. If the user does not permit access, do not assume that either variable contains a location; design the ViewModel flow to handle the absence of location data.

When to use the Navigator API instead

The two variable names provide the built-in geolocation convention described on this page. For custom device integration, capability checks, permission handling, or access to other browser and device features, use an EXT_Component with the JavaScript Navigator API. See Integrate Device Features in MDriven Apps Using the Navigator API.

Related client values

MDriven also recognizes vClientScreenWidth as a client-value naming convention. It is separate from geolocation.

See also