Camera Controls
Using Mappedin SDK for iOS with your own map requires a Solutions license. Try a demo map for free or refer to the Pricing page for more information.
To create rich experiences on top of the Mappedin SDK for iOS, it's useful to be able to control the map view programmatically. This guide shows how to focus the map view on targets, how to listen to camera events and how to control the camera.
Note: A complete class that uses the code snippets in this guide can be found in the Mappedin iOS Github repo: CameraControlsVC.swift
Focus the Camera on Targets
To focus on a polygon after it has been touched, we use the onPolygonClicked()
function in the MPIMapViewDelegate. In this case, we are targeting only the touched polygon. However, we can also give coordinates or nodes as MPIOptions.CameraTargets.
func onPolygonClicked(polygon: MPIPolygon) {
mapView?.cameraManager.focusOn(targets: MPIOptions.CameraTargets(polygons: [polygon]))
}