iOS DocC Documentation: User Interactions (#2608)

This commit is contained in:
Bart Louwers
2024-07-14 22:45:39 +02:00
committed by GitHub
parent 31bf973f67
commit 4ab2316f49
6 changed files with 53 additions and 41 deletions

View File

@@ -18,7 +18,7 @@ By default, Chinese hanzi, Japanese kana, and Korean hangul characters (CJK) are
First, the map attempts to apply a font that you specify the same way as you would specify a server-side font: in [Maputnik](https://maputnik.github.io), in the `text-font` layout property in style JSON, or in the `MLNSymbolStyleLayer.textFontNames` property at runtime. Instead of downloading the glyphs, the map tries to find a [system font](https://developer.apple.com/fonts/system-fonts/) or a font [bundled with your application](https://developer.apple.com/documentation/uikit/text_display_and_fonts/adding_a_custom_font_to_your_app) that matches one of these fonts based on its family name (for example, “PingFang TC”), display name (“PingFang TC Ultralight”), or PostScript name (“PingFangTC-Ultralight”).
If the symbol layer does not specify an available font that contains the required glyphs, then the map tries to find a matching font in the `MLNIdeographicFontFamilyName` [Info.plist key](doc:Info.plist_Keys). Like the ``MLNSymbolStyleLayer.textFontNames`` property, this key can contain a family name, display name, or PostScript name. This key is a global fallback that applies to all layers uniformly. It can either be a single string or an array of strings, which the map tries to apply in order from most preferred to least preferred.
If the symbol layer does not specify an available font that contains the required glyphs, then the map tries to find a matching font in the `MLNIdeographicFontFamilyName` [Info.plist key](doc:Info.plist_Keys). Like the ``MLNSymbolStyleLayer/textFontNames`` property, this key can contain a family name, display name, or PostScript name. This key is a global fallback that applies to all layers uniformly. It can either be a single string or an array of strings, which the map tries to apply in order from most preferred to least preferred.
Each character is rendered in the first font you specify that has a glyph for the character. If the entire list of fonts is exhausted, the map uses the system’s font cascade list, which may vary based on the device model and system language.

View File

@@ -0,0 +1,52 @@
# User Interactions
Learn how to work with gesture recognizers
MapLibre Native iOS provides a set of built-in gesture recognizers. You can customize or supplement these gestures according to your use case. You see what gesture recognizers are on your ``MLNMapView`` by accessing the `gestureRecognizers` property on your map.
## Configuring user interaction
Several properties on an ``MLNMapView`` provide ways to enable or disable a set of gesture recognizers. Boolean values are set to `true` by default.
- ``MLNMapView/zoomEnabled`` - Allows the user to zoom in or out by pinching two fingers, double-tapping, tapping with two fingers, or double-tapping then dragging vertically. Accepts Boolean values.
- ``MLNMapView/scrollEnabled`` - Allows the user to scroll by dragging or swiping one finger. Accepts Boolean values.
- ``MLNMapView/rotateEnabled`` - Allows the user to rotate by moving two fingers in a circular motion. Accepts Boolean values.
- ``MLNMapView/pitchEnabled`` - Allows the user to tilt the map by vertically dragging two fingers. Accepts Boolean values.
- ``MLNMapView/decelerationRate`` - Determines the rate of deceleration after the user lifts their finger. You can set the value using the ``MLNMapViewDecelerationRateNormal``, ``MLNMapViewDecelerationRateFast``, or ``MLNMapViewDecelerationRateImmediate`` constants.
## Individual gestures
|Gesture | Description | Related Property |
|:-------:|----------------| -----------|
|Pinch | Zooms in or out on the map's anchor point | ``MLNMapView/zoomEnabled`` |
|Rotation | Changes the ``MLNMapView`` direction based on the user rotating two fingers in a circular motion | ``MLNMapView/rotateEnabled`` |
|Single tap | Selects/deselects the annotation that you tap. | |
|Double tap | Zooms in on the map's anchor point | ``MLNMapView/zoomEnabled`` |
|Two-finger tap | Zooms out with the map's anchor point centered | ``MLNMapView/zoomEnabled`` |
|Pan | Scrolls across mapView (_note: if_ `MLNUserTrackingModeFollow` _is being used, it will be disabled once the user pans_)| ``MLNMapView/scrollEnabled`` |
|Two-finger drag | Adjusts the pitch of the ``MLNMapView`` | `pitchEnabled` |
|One-finger zoom | Tap twice; on second tap, hold your finger on the map and pan up to zoom in, or down to zoom out | ``MLNMapView/zoomEnabled`` |
@Video(
source: "rotation.mp4",
poster: "rotation.png",
alt: "A short video showing the gesture for rotation with two fingers.") {
Rotation with two fingers.
}
@Video(
source: "quickzoom.mp4",
poster: "quickzoom.png",
alt: "A short video showing rotation with one finger.") {
One finger zoom with a double tap.
}
## Adding custom gesture recognizers
You can add [`UIGestureRecognizer`s](https://developer.apple.com/documentation/uikit/uigesturerecognizer) to your map programmatically or via storyboard. Adding custom responses to gesture recognizers can enhance your user's experience, but try to use standard gestures where possible.
The gesture recognizers that you add will take priority over the built-in gesture recognizer. You can also set up your own gesture recognizer to work simultaneously with built-in gesture recognizers by using [`gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:`](https://developer.apple.com/documentation/uikit/uigesturerecognizerdelegate/1624208-gesturerecognizer), allowing you to enhance already existing gesture recognizers.
You can also add gesture recognizers that are only called when the default gesture recognizer fails (and vice versa), such as when a user taps on a part of the map that is not an annotation. The documentation for ``MLNMapView`` includes an example of how to create a fallback gesture recognizer.
If you would like to disable a specific set of gesture recognizers, such as zoom, you can set the Boolean value for the appropriate property to `false`. You can then add your own gesture recognizers to perform those actions.

View File

@@ -6,8 +6,6 @@ MapLibre Native for iOS supports custom `Info.plist` keys in your application in
If it is required by the tileserver you use, set the API key to be used by all instances of ``MLNMapView`` in the current application.
As an alternative, you can use ``MLNSettings.accessToken`` to set a token in code.
## MLNAccuracyAuthorizationDescription
Set the accuracy authorization description string as an element of `NSLocationTemporaryUsageDescriptionDictionary` to be used by the map to request authorization when the `MLNLocationManager.accuracyAuthorization` is set to `CLAccuracyAuthorizationReducedAccuracy`. Requesting accuracy authorization is available for devices running iOS 14.0 and above.

View File

@@ -1,38 +0,0 @@
# User Interactions
The Mapbox Maps SDK for iOS provides a set of built-in gesture recognizers. You can customize or supplement these gestures according to your use case. You see what gesture recognizers are on your `MLNMapView` by accessing the `gestureRecognizers` property on your map.
## Configuring user interaction
Several properties on an `MLNMapView` provide ways to enable or disable a set of gesture recognizers. Boolean values are set to `YES` by default.
- `zoomEnabled` - Allows the user to zoom in or out by pinching two fingers, double-tapping, tapping with two fingers, or double-tapping then dragging vertically. Accepts Boolean values.
- `scrollEnabled` - Allows the user to scroll by dragging or swiping one finger. Accepts Boolean values.
- `rotateEnabled` - Allows the user to rotate by moving two fingers in a circular motion. Accepts Boolean values.
- `pitchEnabled` - Allows the user to tilt the map by vertically dragging two fingers. Accepts Boolean values.
- `decelerationRate` - Determines the rate of deceleration after the user lifts their finger. You can set the value using the `MLNMapViewDecelerationRateNormal`, `MLNMapViewDecelerationRateFast`, or `MLNMapViewDecelerationRateImmediate` constants.
## Individual gestures
|Gesture | Description | Related Property |
|:-------:|----------------| -----------|
|Pinch | Zooms in or out on the map's anchor point | `zoomEnabled` |
|Rotation | Changes the MLNMapView direction based on the user rotating two fingers in a circular motion | `rotateEnabled` |
|Single tap | Selects/deselects the annotation that you tap. | |
|Double tap | Zooms in on the map's anchor point | `zoomEnabled` |
|Two-finger tap | Zooms out with the map's anchor point centered | `zoomEnabled` |
|Pan | Scrolls across mapView (_note: if_ `MLNUserTrackingModeFollow` _is being used, it will be disabled once the user pans_)| `scrollEnabled` |
|Two-finger drag | Adjusts the pitch of the `MLNMapView` | `pitchEnabled` |
|One-finger zoom | Tap twice; on second tap, hold your finger on the map and pan up to zoom in, or down to zoom out | `zoomEnabled`|
![quick zoom](img/user-interaction/quickzoom.gif) ![rotation](img/user-interaction/RotateSydney.gif)
## Adding custom gesture recognizers
You can add `UIGestureRecognizers` to your map programmatically or via storyboard. Adding custom responses to gesture recognizers can enhance your user's experience, but try to use standard gestures where possible.
The gesture recognizers that you add will take priority over the built-in gesture recognizer. You can also set up your own gesture recognizer to work simultaneously with built-in gesture recognizers by using `-gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:`, allowing you to enhance already existing gesture recognizers.
You can also add gesture recognizers that are only called when the default gesture recognizer fails (and vice versa), such as when a user taps on a part of the map that is not an annotation. The documentation for [MLNMapView](Classes/MLNMapView.html) includes an example of how to create a fallback gesture recognizer.
If you would like to disable a specific set of gesture recognizers, such as zoom, you can set the Boolean value for the appropriate property to `NO`. You can then add your own gesture recognizers to perform those actions.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 677 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 775 KiB