The capture-coordinates component was visually updated in version 4.82.0 of JourneyApps Runtime.
The capture-coordinates component allows users to capture their current location. The captured location will be displayed on a map with a marker.
Basic Examples
Capture coordinates & markers
The following example shows how GPS location capturing can show a mix between marker-query and marker nodes.
In the example the captured location will be bound to the variable specified in the capture-coordinatesbind attribute. Markers are simply locations that are being visually highlighted on a map. This is useful to, for example, show where the captured location is in relation to other points of interest.
<var name="current_location" type="location" />
<var name="markers" type="query:location" />
<capture-coordinates bind="current_location">
<marker label="You are here" bind="current_location" icon="fa-home" />
<marker-query query="markers" latitude="{location.latitude}" longitude="{location.longitude}" label="This is an example label" />
</capture-coordinates>
"Foreground" Capturing
The following example shows how GPS location capturing can be performed in the "foreground" i.e. the user sees a map showing how their GPS location is captured.
Using the show-if configuration option, it is also possible to capture a GPS location in the background (i.e. the map pictured in the screenshot above is not shown)
The capture-coordinates component uses the GPS location of the device and sets this value on the bind variable/field. This value will update as accuracy increases of the device's GPS location. A marker will autogenerate at the bound location if no <marker /> or <marker-query /> is defined. See show-markers for more information on hiding markers.
Must be a variable or field of type location. See the reference on data model fields for more details.
The following component methods are available when an id is assigned to the component and component.captureCoordinates({id:'my-id'}) / component.displayCoordinates({id:'my-id'}) is called from JS/TS:
getMapState
Version compatibility
getMapState was introduced in version 4.82.0 of the JourneyApps Runtime.
Programmatically retrieve the current state of the map which will contain the current center and zoom position of the map.