Blue Dot

Displaying user position inside a building is not accurate with just GPS. However, there are a multitude of Indoor Positioning Systems utilizing different technological approaches to providing an accurate and reliable positioning inside. Mappedin works with any IPS capable of providing the SDK with latitude, longitude and floor level information.

A complete class that uses the code snippets in this guide can be found in the Mappedin iOS Github repo: BlueDotVC.swift

Enabling Blue Dot

You can initialize and enable the Blue Dot when the map first loads by using the onFirstMapLoaded function implemented by MPIMapViewDelegate. The MPIBlueDotManager can be easily enabled with default settings by calling mapView.blueDotManager.enable(MPIOptions.BlueDot()).

There are two useful events to listen to: position update and state change. For debugging purposes, you could add print statements to the following functions. Position updates could be useful for reacting to a user entering or leaving a certain radius of a store. Status updates help handle situations where the position is no longer available.

func onFirstMapLoaded() {
mapView?.blueDotManager.enable(MPIOptions.BlueDot())
}
func onBlueDotPositionUpdate(update: Mappedin.MPIBlueDotPositionUpdate) {
print(update.position)
}
func onBlueDotStateChange(stateChange: Mappedin.MPIBlueDotStateChange) {
print(stateChange.name)
print(stateChange.reason)
}

Simulating Blue Dot

To display a Blue Dot with the SDK, you'll need the position information in the form of MPICoordinates. The following is a point in the fictional Mappedin Demo Mall with an accuracy of 2 meter radius on the floor level 0.

let coords = MPICoordinates(latitude: 43.52012478635707, longitude: -80.53951744629536, accuracy: 2.0, floorLevel: 0)

Using our sample coordinate, we can draw the Blue Dot on the map by creating an MPIPosition and passing it to blueDotManager.updatePosition().

func onFirstMapLoaded() {
mapView?.blueDotManager.enable(options: MPIOptions.BlueDot())
let coords = MPICoordinates(latitude: 43.52012478635707, longitude: -80.53951744629536, accuracy: 2.0, floorLevel: 0)
let position = MPIPosition(timestamp: 1.0, coords: coords)
mapView?.blueDotManager.updatePosition(position: position)
}

iOS Blue Dot

Note: A complete class that uses the code snippets in this guide can be found in the Mappedin iOS Github repo: BlueDotVC.swift

Blue Dot Display States

  • When the Blue Dot position given to the Mappedin Web SDK has a high accuracy (within a few meters) and is on the floor currently displayed, it is displayed as bright blue.

Blue Dot - Accurate

  • If the Mappedin Blue Dot is able to detect that a given position update is inaccurate, a semi-transparent blue shadow is displayed underneath the Blue Dot to indicate uncertainty range.

Bluedot Inaccurate

  • When the BlueDot is on another floor it will look semi-transparent.

Blue Dot - Accurate on another floor

  • The uncertainty range is shown also when displaying the Blue Dot on another floor than the currently viewed one.

Blue Dot Inaccurate on another floor

  • 30 seconds after the latest position update, the BlueDot is displayed as greyed out as it's possible that the user has moved but no updates have been received.

Blue Dot - Outdated

Wayfinding From Blue Dot

A common map feature is to provide a user with directions from their current location. The Mappedin Web SDK is able to provide the nearest node to the user’s location, which can be used as the starting point for wayfinding. Pass the user’s destination to the getDirections method to create a directions object that can be used to draw the path.

func onBlueDotPositionUpdate(update: Mappedin.MPIBlueDotPositionUpdate) {
let destination = mapView?.venueData?.locations.first(where: { $0.name == "Destination Name" })
mapView?.getDirections(to: destination!, from: update.nearestNode!) {
directions in
self.mapView?.journeyManager.draw(directions: directions!)
}
}

A complete class that uses the code snippets in this guide can be found in the Mappedin iOS Github repo: BlueDotVC.swift

Camera Follow Mode

In some instances, a user may pan the camera away and lose track of their own Blue Dot position. An app may want to snap the camera to the user's location to reorient themselves. While this could also be done using camera controls, an app can also leverage the map STATE to pin the camera to the Blue Dot's location.

By default, the map starts in EXPLORE mode allowing the user to freely control the camera position. To pin the camera to the Blue Dot, set the camera state to FOLLOW with Blue Dot enabled.

mapView?.blueDotManager.enable(options: MPIOptions.BlueDot(smoothing: true))
mapView?.blueDotManager.setState(state: MPIState.FOLLOW)

The camera will animate to the Blue Dot position whenever it is updated, however, it doesn't zoom or rotate. When providing wayfinding directions, it may be beneficial to orient the camera along the route. Enable this by setting useRotationMode of MPIOptions.BlueDot to true to when calling MPIBlueDotManager.enable().

Rotation mode only works when using the MPIJourneyManager. The camera will not rotate with a path created using MPIPathManager. You can read more about path differences in the A-B Wayfinding guide.

mapView?.blueDotManager.enable(
options: MPIOptions.BlueDot(smoothing: true, useRotationMode: true))
mapView?.blueDotManager.setState(state: MPIState.FOLLOW)

Additional Reading

Was this page helpful?

Next Topic

Search