Giter VIP home page Giter VIP logo

mapbox-maps-ios's Introduction

mapbox-maps-ios

CLA assistant

The Mapbox Maps SDK for iOS is a public library for displaying interactive, thoroughly customizable maps in native iOS. It takes map styles that conform to the Mapbox Style Specification, applies them to vector tiles that conform to the Mapbox Vector Tile Specification, and renders them using Metal.

Getting Started

This README is intended for developers who are interested in contributing to the Mapbox Maps SDK for iOS. Please visit https://docs.mapbox.com/ios/maps/guides/ for general information and instructions on using the Maps SDK in your iOS application.

Examples App

The Examples app shows how to use many of the features in the Maps SDK. See the Examples README for more information.

Developing

If you are interested in contributing to the Maps SDK, please see the DEVELOPING.md file for information on setting up, running and building the SDK.

Reporting issues / Need help?

Report a bug 🪲

Please use our bug template to report any issues.

Request a new feature or enhancement 🍏

Please use our feature template to request new features or enhancements.

Other questions

If you have any questions about how to use the SDK or if you need help with specific features, you can reach out to our support team via our website or connect with our developer community by joining our Discord channel. We kindly ask you to avoid using the issue tracker in this repository for questions and instead use our support channels.

Historical Note

This repository is a continuation of the Mapbox Maps SDK for iOS available at mapbox/mapbox-gl-native-ios.

mapbox-maps-ios's People

Contributors

1ec5 avatar aleksproger avatar anderco avatar ank27 avatar astojilj avatar baleboy avatar captainbarbosa avatar chriswhong avatar cmilack avatar dependabot[bot] avatar endanke avatar evil159 avatar jmkiley avatar kylmakalle avatar macdrevx avatar maios avatar nishant-karajgikar avatar niwakadev avatar odnairy avatar ottylab avatar paulsusername avatar pengdev avatar persidskiy avatar pjleonard37 avatar s2ler avatar sbma44 avatar sosthoff avatar tatiana-yan avatar tobrun avatar zizasaurus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mapbox-maps-ios's Issues

Bearing arrow option when showing user location

In the old mapbox version, you could easily show the user location with "mapView.showsUserHeadingIndicator = true".

There is even an asset for it here: https://github.com/mapbox/mapbox-maps-ios/tree/6f0555d0727c92b9ffafbf1adde2d450253271a6/Sources/MapboxMaps/Location/Pucks/IndicatorAssets.xcassets/triangle.imageset

I have not found any easy way to just add this triangle to the location puck. You can't use it in creating a new puck because of an 'internal' protection level.

Is there a way to do this currently, or will this be added in the future?

Support for larger glb files and textures?

New Feature

I tried using ModelExample.swift to load a larger glb with around 300k or so vertices. The model did not render correctly ( no texture, and lots of artifacts. ) The console logged a warning a maximum vertex count being reached, though I don't have the text anymore. Is there a setting or something I could change to enable larger files? Or perhaps a different file format that supports bigger models? If not, would some custom metal rendering be possible, and if so where might be a good place to start to learn more about that?

Why

Loading larger models ( 500k - 1m vertices ) with textures ( 2k - 8k ) would be very useful to my application.

Thanks

GestureManager does not notify delegate for tap or quickZoom

Environment

  • Xcode version: 12.4
  • iOS version: 14.4
  • Devices affected: any
  • Maps SDK Version: beta.13

Observed behavior and steps to reproduce

  • Assign an instance of a GestureManagerDelegate adopting type to a MapView's gestureManager.delegate property
  • note that GestureManagerDelegate method gestureBegan(for:) is not called for GestureType of tap or quickZoom, but that it is called for pinch, pan, rotate and pitch.

Expected behavior

A tap gesture should invoke gestureBegan(for:)

Notes / preliminary analysis

Tried assigning the gestureManager.delegate at different points in a MapView's lifecycle to no avail.

Additional links and references

Black view appears before loading style

Environment

  • Xcode version: 12.2
  • iOS version: 14.0
  • Devices affected: Saw on iPhone 11 Pro and iPhone 8 devices
  • Maps SDK Version: v10.0.0-beta.15

Observed behavior and steps to reproduce

When transitioning to a UIViewController that contains a MapView, there can be a black screen for a few seconds before either the map style's background color loads or the style loads.

black screen

Expected behavior

For the style's background color or style itself to load without a black screen.

Notes / preliminary analysis

DebugViewController that repros the issue
import UIKit
import MapboxMaps
import Turf
/**
 NOTE: This view controller should be used as a scratchpad
 while you develop new features. Changes to this file
 should not be committed.
 */
public class DebugViewController: UIViewController {
    internal var mapView: MapView!
    var resourceOptions: ResourceOptions {
        guard let accessToken = AccountManager.shared.accessToken else {
            fatalError("Access token not set")
        }
        let resourceOptions = ResourceOptions(accessToken: accessToken)
        return resourceOptions
    }
    override public func viewDidLoad() {
        super.viewDidLoad()
        self.mapView = MapView(with: view.bounds, resourceOptions: resourceOptions)
        mapView.update { (mapOptions) in
            mapOptions.location.showUserLocation = true
        }
        self.view.addSubview(mapView)
        let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap))
        mapView.addGestureRecognizer(tap)
    }
    @objc private func handleTap() {
        let vc = SecondDebugViewController()
        self.present(vc, animated: false) {
            print("done")
        }
    }
}
class SecondDebugViewController: DebugViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        mapView.style.styleURL = .satellite
        let tap = UITapGestureRecognizer(target: self, action: #selector(handleMapTap))
        mapView.addGestureRecognizer(tap)
    }
    @objc private func handleMapTap() {
        self.dismiss(animated: false) {
            print("bye bye")
        }
    }
}

Additional links and references

View-based Annotations

New Feature

Is there a plan to support view-based annotations in v10, as you have for the previous Mapbox versions? If so, when do you plan on releasing it?

Why

I understand the annotations are now based on style layers, but image-based annotations are very limiting. Our previous code rely on view-based annotations for custom shapes and animations within the annotation. Specifically, our application has video previews on the map, marquee-label animations for showing text at a specific location, and custom text bubble bezier paths for annotations.

[Example] Change puck bearing example

We need to create an example that will show how to change the bearing of the puck that is located in Location framework.

The android SDK has this example and we need to add it to the examples app as well.

Info view cannot be hidden

New Feature

The Maps SDK for iOS v10 documentation states: "You must display attribution on maps unless the map's data comes entirely from non-Mapbox sources." As this implies that the attribution's visibility should be configurable, the SDK should make it so.

Yet, the SDK does not appear to provide a means to hide the attribution. A MapOptions ornaments property provides showsAttributionButton but it is a get-only property that is always true.

More, this code appears to fundamentally disagree with the above quoted statement:

internal func ensureTelemetryOptOutExists() {

It is equally unclear how a developer might affect the value of telemetryOptOutShownInApp as OrnamentConfig cannot be constructed as it has no public initializers.

Why

The Mapbox SDK can be used without any Mapbox sourced data.

[annotations] Custom styling for annotations

New Feature

Add convenience initializers for the following annotations:

  • NOTE: the default style should be that in the style layer itself

PointAnnotation

PointAnnotation(coordinate:color:)

LineAnnotation

LineAnnotation(coordinates:color:lineWidth)

PolygonAnnotation

PolygonAnnotation(coordinates:color:outlineColor)
  • After adding the above convenience initializer, we need to expose a way for those properties to be updated via an update function that will be on those annotations.

Why

Makes it a little easier for developers to add custom styling, otherwise by default PointAnnotation just uses a red pin, and LineAnnotation and PolygonAnnotation colors are black by default.

Implementation advice

For PointAnnotation, we'll need to pass along the specified color to defaultAnnotationImage here. The default image also has a secondary color and tertiary color, so we probably need to alter the incoming specified color to be two and three levels darker than the incoming specified color for this to look ok.

For all annotations, we'll need to add additional expression logic to the methods inside updateStyleLayer(for annotation: Annotation) to support adding multiple annotations of the same type but with different colors, to ensure for example, a developer could add a red PointAnnotation and a blue PointAnnotation at the same time.

I'd also propose making the styling properties introduced here get-only for now, and to only support these line width and color properties. Any other styling that is more advanced should make use of the Style APIs directly.

Modifying a property of the layout property of a stylelayer has no effect

Environment

  • Xcode version: 12.3
  • iOS version: 14.3
  • Devices affected: All
  • Maps SDK Version: v10 beta 12

Observed behavior and steps to reproduce

var result = self.mapView.style.getLayer(with: id, type: LineLayer.self)
if case .success(var lineStyleLayer) = result {
    lineStyleLayer.layout!.visibility = .visible
}

Has no effect on the visibility of the stylelayer.

But if one does:

self.mapView.style.removeStyleLayer(forLayerId: id)
self.mapView.style.addLayer(layer: lineStyleLayer)

...then the stylelayer is visible. BUT one had to remove the stylelayer from style, and so order is lost -- unless you are expecting developers to have all stylelayer identifiers and layer positions at the ready when they want to change the visibility of a stylelayer.

Expected behavior

Changing the visibility property of the layout of a stylelayer should make the stylelayer visible.

Notes / preliminary analysis

Additional links and references

Support for 3D Lines and points

Is there now or is there going to be support for 3D lines and points? For example, you may want to view the flight path of an aircraft in 3D - above the ground.

Can you do this now?

CameraOptions for 3D maps

New Feature

CameraOptions should include following params for 3D maps:

  • location:
    Coordinates defining where camera should be put on the map. Implies that camera's y-value corresponds to terrain altitude at location
  • elevation:
    Defaulting to 0, defining the camera elevation from the ground. Absolute camera height accordingly equals altitude + elevation.
  • bearing:
    Rotate camera around y-axis (look left and right)
  • tilt:
    Rotate camera around x-axis (look up and down)

Why

  • When working with 3D terrain, setting camera with axis corresponding to x = left/right, y = up/down, z=front/back is more intuitive
  • Adds possibility of setting first-person view (FPV) for AR experiences

Support Cluster inspection methods

New Feature

It doesn't seem like I can access the cluster inspection methods at this point. would love to be able to get the expansion zoom and leaves from a cluster id

Why

Clusters are pretty hard to work with if you can't get any information about them. Not sure if these methods are not available or I can't find them in the documentation

MapboxMobileEvents version requirement is too strict

When using SPM or CocoaPods, MapboxMaps requires exactly v0.10.8 of MapboxMobileEvents. It should be more flexible, allowing for any patch version of MapboxMobileEvents from v0.10.8 (or thereabouts) up to but not including v0.11.0.

m.dependency 'MapboxMobileEvents', '0.10.8'
.package(name: "MapboxMobileEvents", url: "https://github.com/mapbox/mapbox-events-ios.git", .exact("0.10.8")),

For reference, when using Carthage, MapboxMaps is compatible with MapboxMobileEvents from v0.10.0 up to but not including v0.11.0:

github "mapbox/mapbox-events-ios" ~> 0.10

MapboxCoreNavigation, MapboxSearch, and MapboxVision similarly use the “tadpole operator” for their MapboxMobileEvents dependencies.

/ref #118
/cc @neelmistry94 @macdrevx

Unable to set image for point annotation

Environment

  • Xcode version: 12.3
  • iOS version: 14.3
  • Devices affected: iPhone X
  • Maps SDK Version: v10 public beta

Observed behavior and steps to reproduce

Unable to change image of a point annotation using the following code:

            let image = UIImage(named: "star")
            annotation.image = image
            try? mapView.annotationManager.updateAnnotation(annotation)

Simulator Screen Shot - iPhone 11 - 2021-02-03 at 19 43 54

Expected behavior

Should be able to set the image for the annotation, update the annotation and have the expected image show. Am I calling something incorrectly?

Notes / preliminary analysis

Additional links and references

Map will only move down after setCamera to zoom level 13

Environment

  • Xcode version: 12.3
  • iOS version: 14.3 on simulator and actual device
  • Devices affected: simulator, iPhone 6s, 11Pro
  • Maps SDK Version: 10.0.0-beta.13

Observed behavior and steps to reproduce

With terrain, after animating camera to a map location at zoom level 13, on any swipe gesture to move the map up, down, left, or right, the map will only move down, and appears to move down faster on a down gesture than either left or right or up.

Steps to recreate:

After creating a MapView and adding it as subview of the view controller view, do:

mapView.update { mapOptions in
    mapOptions.location.showUserLocation = true
    mapOptions.ornaments.showsScale = true  //default value
    mapOptions.camera.maximumPitch = 85
    mapOptions.camera.maximumZoomLevel = 21
}

Then set initial camera:

self.mapView.isUserInteractionEnabled = false
let centerCoordinate = CLLocationCoordinate2D(latitude: 39.39305, longitude: -97.56589)
self.mapView.cameraManager.setCamera(centerCoordinate: centerCoordinate, zoom: 2.0, bearing: 0, pitch: 0)
mapView.on(.mapLoadingFinished) { [weak self] event in
    guard let self = self else { return }
    let mtHood = CLLocationCoordinate2D(latitude: 45.37373, longitude: -121.69704)
    let startLocation = self.mapView.locationManager.latestLocation?.coordinate ?? mtHood
    let cameraOptions = CameraOptions(center: startLocation, zoom: 13.0, bearing: 0, pitch: 30.0)
    self.mapView.cameraManager.setCamera(to: cameraOptions, animated: true, duration: 0.6) { _ in
        self.mapView.isUserInteractionEnabled = true
    }
}

Video:
https://user-images.githubusercontent.com/39099029/108400390-fce58000-71cf-11eb-834d-4e1d2c2cc9fe.mov
Note that after a zoom out gesture, the issue is resolved. Not shown in the video, but any pinch zoom gesture, in or out, resolves the issue.

Interestingly, if the center point is nil, in which case the camera center remains the centerCoordinate value above, then the issue does not occur:
let cameraOptions = CameraOptions(center: nil, zoom: 13.0, bearing: 0, pitch: 30.0)
https://user-images.githubusercontent.com/39099029/108402444-66668e00-71d2-11eb-9efc-7a9c89fbe716.mov

Perhaps the issue depends on the elevation of the initial center point. The location that the simulator zooms to for user location is latitude: 36.75744, longitude: -121.40073.

Also see the issue on actual device, which uses my actual location in Portland, OR.

If I change the zoom value to 11.0 in CameraOptions, the issue does not occur.

If I set initial pitch to 0, when move completes immediately pitch the camera up, then issue reverses itself: any swipe gesture only moves the camera forward. Again, any zoom gesture restores expected behavior.

Expected behavior

Map gestures work correctly after the sequence of events above at any map location, zoom level, pitch, and orientation.

Notes / preliminary analysis

Much detail above. Happy to experiment with other situations that you might suggest.

Additional links and references

Unable to toggle scaleBar and compass ornament visibility

When trying to toggle the scaleBar and compass ornaments, I am unable to do so unless I initially set them to false in viewDidLoad. Is this expected behavior? Additionally, is there any plan to allow developers to toggle the visibility of the scaleBar similarly to the compass (ie. mapOptions.ornaments.compassVisibility = .visible)?

pixelForCoordinate issue with terrain

Returned values are incorrect. Works as intended in 2D.

E.g. returned values look wrong (screenshots): when model is on top, returned y is 352; on bottom, it is 476; for middle of the screen placement, pixelForCoordinate returns 409.

Screen Shot 2021-03-03 at 15 50 27
Screen Shot 2021-03-03 at 15 49 56
Screen Shot 2021-03-03 at 15 48 56

StyleURI should be a struct

StyleURI appears to have the same semantics as what’s called an extensible enumeration in Objective-C. In Swift, it would be more elegant to represent it as a struct: the cases would become static lets, and the custom(url:) case would go away in favor of the existing StyleURI(rawValue:) initializer, which would be much simpler. This is the same way an Objective-C extensible enumeration gets bridged to Swift.

A struct would be more maintainable than the existing approach, especially if the set of available named styles changes in the future: there would be only one place to update instead of keeping four different parts of the file in sync. Anyone who needs to specify a custom URL can write .init(rawValue: …) instead of having to choose between .init(rawValue: …) and .custom(url: …); the choice may not be obvious to a developer who doesn’t have the implementation code on hand.

/// Enum representing the latest version of the Mapbox styles (as of publication). In addition,
/// you can provide a custom URL or earlier version of a Mapbox style by using the `.custom` case.
public enum StyleURI: Hashable, RawRepresentable {
public typealias RawValue = URL

For reference, the MapboxDirections library has a DirectionsProfileIdentifier struct with similar semantics.

/cc @mapbox/maps-ios

Customizable Annotation styling

New Feature

Currently PointAnnotations are clustered. It would be nice to be able to configure whether or not clustering is used, or control its radius and max zoom, like with GeoJSONSource. It would also be nice to be able to set an image offset as currently the image center is placed coincident with the ray cast from the camera's perspective point to the coordinate. For the default red marker pin, this has the effect that the pin does not point at the coordinates and as one rotates a pitched map, the pointer refers to an infinite number of other map coordinates, just never the actual coordinate.

Currently LineAnnotations are thin and black. This styling is not ideal for all background tile appearances, such as atop aerial imagery. It would be nice to be able to customize the styling of LineAnnotations, i.e., color, width, pattern, endpoints, and to be able to add edge labels.

Currently ShapeAnnotations are black and opaque. It would nice to be able to separately control edge color, width, pattern and endpoints, and to be able to add edge labeling. It would also be nice to be able to control fill color and fill opacity, as well as add a label at a smart center point in the polygon.

Why

Point annotations should be able to point directly to a map coordinate.
Clustering of point annotations is not always preferred.
Customizable styling of line and polygon annotations would allow adapting appearance for optimal readability, as well as for other considerations.
Labeling annotations allows for presenting additional pertinent information such as distance or area..

Map scrolls horizontally after swiping quickly vertically

Environment

  • Xcode version: Xcode 12.2
  • iOS version: iOS 14.0
  • Devices affected: iPhone X
  • Maps SDK Version: main at 511e58d

Observed behavior and steps to reproduce

  1. Pan close to either Antarctica or the Arctic Circle.
  2. Swipe quickly towards that continent.
  3. The map quickly scrolls east or west.

Gif showing the map being swiped

Expected behavior

The map should rebound north or south, depending on whether near Antarctica or the Arctic.

Notes / preliminary analysis

While more noticeable when the map's pitch is not 0, it can be observed when the map is not tilted.

Additional links and references

Expose utility functions for CoordinateBounds

New Feature

Expose functions: getCenter, contains, union, intersect, containsLatitude, containsLongitude, include, getLatitudeSpan, getLongitudeSpan as extension functions for CoordinateBounds.

Full definition of Android LatLngBounds(ancestor for CoordinateBounds) could be found here on Android platform. iOS equivalent for it in previous Maps version is MGLCoordinateBounds that also was exposing some functions but not truly aligned with Android.

Why

Better parity with Android platform.

Carthage support

New Feature

Carthage is NOT currently supported.

Why

Carthage is preferred; support for cached builds vastly improves build times.

NSException when attempting to call Style.getLayer() on a text-based SymbolLayer

Environment

  • Xcode version: 12.2
  • iOS version: 14.x
  • Devices affected: iPhone 8, iPhone 11
  • Maps SDK Version: 10.0.0-beta.12

Observed behavior and steps to reproduce

An error occurs when accessing a SymbolLayer that contains a value for SymbolLayer.textField.

Code that reproduces the issue courtesy of @captainbarbosa.

Code to reproduce
// Add to viewDidLoad()
        mapView.on(.mapLoadingFinished) { [weak self] _ in
            guard let self = self else { return }
            self.updateStyle()
        }
func updateStyle() {
    let pointFeature = Feature(geometry: Geometry.point(Point(.mapView.centerCoordinate)))

    var geoJSONSource = GeoJSONSource()
    geoJSONSource.data = .feature(pointFeature)

    let sourceId = "my-source"
    let layerId = "my-layer"

    var symbolLayer = SymbolLayer(id: layerId)
    symbolLayer.layout?.textField = .constant("Hello world!")
    symbolLayer.source = sourceId

    _ = mapView.style.addSource(source: geoJSONSource, identifier: sourceId)
    _ = mapView.style.addLayer(layer: symbolLayer, layerPosition: nil)

    let getLayerResult = mapVC.style.getLayer(with: layerId, type: SymbolLayer.self)

    switch getLayerResult {
    case .success(let layer):
        debugPrint("✅ Got layer: \(layer)")
    case .failure(let error):
        debugPrint("❌ Got error: \(error)")
    }

You then hit an error in Style.getLayer().


Thread 1: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=com.mapbox.bindgen Code=-2 "*** 
-[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: fontStack)" UserInfo={NSUnderlyingErrorKey=*** 
-[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: fontStack), NSLocalizedFailureReason=*** 
-[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: fontStack)}

Expected behavior

The layer is successfully returned or fails gracefully.

Notes / preliminary analysis

There seem to be a couple of issues:

  1. According to the Mapbox Style Specification, text-field should be of type Formatted, whereas we have it as a String. We should implement Formatted to handle formatted strings.
  2. Properties that should be optional are being required. We should figure out where this requirement is happening, then address it. While investigating, also ran into errors because there wasn't a value for image when retrieving a layer containing text.

Additional links and references

cc @nishant-karajgikar

Unexpected networking-related messages logged to console

Environment

  • Xcode version: 12.x
  • iOS version: 14.x
  • Devices affected: Simulators & Devices
  • Maps SDK Version: v10.0.0-beta.15

Observed behavior and steps to reproduce

In some situations, especially during map animations, messages similar to the following are logged to the console:

Connection 956: unable to determine interface type without an established connection
Connection 956: unable to determine fallback status without a connection

Expected behavior

No logging.

Notes / preliminary analysis

We've identified that this issue seems to occur occasionally when the SDK cancels a URLSessionTask. We've created a test case that reproduces the issue independently from any of the Mapbox SDKs and have opened a bug with Apple.

No longer able to use expression for `iconAnchor` or `textAnchor` SymbolLayer style properties

Environment

  • Maps SDK Version: 10.0.0-beta.12

Observed behavior and steps to reproduce

In SDK v9 and previous you were able to set the iconAnchor and textAnchor style properties of an MGLSymbolStyleLayer to a data driven expression. This was useful if, for example, you wanted to use annotations that had a stem coming off of either the left or right hand side, like this:

Symbol Layer Stems

It was possible to make the anchor property dependent of a feature attribute that determined the "handed-ness" of the stem.

The corresponding SymbolLayer iconAnchor and textAnchor properties allow for only a constant value and won't accept and expression.

This is a regression in functionality that is very useful.

No longer able to use expression for `iconAnchor` or `textAnchor` SymbolLayer style properties

Environment

  • Maps SDK Version: 10.0.0-beta.12

Observed behavior and steps to reproduce

In SDK v9 and previous you were able to set the iconAnchor and textAnchor style properties of an MGLSymbolStyleLayer to a data driven expression. This was useful if, for example, you wanted to use annotations that had a stem coming off of either the left or right hand side, like this:

Symbol Layer Stems

It was possible to make the anchor property dependent of a feature attribute that determined the "handed-ness" of the stem.

The corresponding SymbolLayer iconAnchor and textAnchor properties allow for only a constant value and won't accept and expression.

This is a regression in functionality that is very useful.

Map zoom animation is shaky

Environment

  • Xcode version: 12.4
  • iOS version: 14.4
  • Devices affected: Looks like all
  • Maps SDK Version: 10.0.0-beta.16 - 10.0.0-beta.17

Observed behavior and steps to reproduce

Starting with Maps SDK v10.0.0-beta.16 zooming animation started to work incorrectly. Sometimes it animates perfectly, but sometimes - it shakes like crazy. I did try to get steps how to reproduce it, but actually there is no steps needed. It does that always, just sometimes it works as expected. See attached video:

shaky_zoom_lq.mp4

The same problem is when zooming using pinch gesture.

Expected behavior

Camera animation is smooth.

Notes / preliminary analysis

Additional links and references

Custom UI and animation when displaying PointAnnotation

New Feature

I would like to have a custom UI (labels, multiple images) and animations when displaying PointAnnotation on the map. The previous version of SDK provides MGLAnnotationView to allow that. I was not able to find an equivalent of that in the new SDK.

Why

The feature is supported in the previous version of SDK.

Annotations seem empty

Environment

  • Xcode version: 12.4
  • iOS version: 14
  • Devices affected:
  • Maps SDK Version: 10.0.0-beta.15

Observed behavior and steps to reproduce

Annotations are added on styleFullyLoaded event but it shows empty after 10 sec of runtime.

`struct Map: UIViewRepresentable {
var myPlaneCoords: CLLocationCoordinate2D

private let mapView = MapView(with: .zero, resourceOptions:  ResourceOptions(accessToken: "xxx"), styleURL: .custom(url: URL(string: "xxx")!))


func makeUIView(context: UIViewRepresentableContext<Map>) -> MapView {
    print("makeUIView")
    mapView.cameraManager.setCamera(to: CameraOptions(center: myPlaneCoords, zoom: 14))
    DispatchQueue.main.asyncAfter(deadline: .now() + 10) {
        print("annotations delayed", mapView.annotationManager.annotations)
    }
    mapView.on(.mapLoadingFinished) { (event) in
        print("mapLoadingFinished")
        let res =  mapView.annotationManager.addAnnotation(myPlane)
        print(res)
    }
    
    mapView.on(.styleLoadingFinished) { (event) in
        print("styleLoadingFinished")
    }
    
    mapView.on(.styleFullyLoaded) { (event) in
        print("styleFullyLoaded")
        let res =  mapView.annotationManager.addAnnotation(myPlane)
        print(res)
    }
    
    
    mapView.update { (mapOptions) in
        mapOptions.ornaments.showsScale = false
    }
    
    return mapView
}

}
`
Console output
styleLoadingFinished
styleFullyLoaded
success(true)
styleFullyLoaded
failure(MapboxMaps.AnnotationManager.AnnotationError.annotationAlreadyExists(Optional("Annotation has already been added.")))
mapLoadingFinished
failure(MapboxMaps.AnnotationManager.AnnotationError.annotationAlreadyExists(Optional("Annotation has already been added.")))
annotations delayed [:]

Expected behavior

Annotations shouldn't be empty

Notes / preliminary analysis

Sometimes it shows them in delayed function maybe I'm adding them in the wrong event?

Additional links and references

Map does not respond to gestures

Environment

  • Xcode version: 12.3
  • iOS version: 14.3
  • Devices affected: iPhone
  • Maps SDK Version: v10 beta12

Observed behavior and steps to reproduce

Map occasionally does not change in response to any gesture. The cameraIsChanging and cameraDidChange fire in pairs throughout the interaction. This seems off, that didChange fires during the gesture.

Expected behavior

The map correctly responds to pan, zoom, rotate and pitch gestures.

Notes / preliminary analysis

Additional links and references

No longer able to use expression for `iconAnchor` or `textAnchor` SymbolLayer style properties

Environment

  • Maps SDK Version: 10.0.0-beta.12

Observed behavior and steps to reproduce

In SDK v9 and previous you were able to set the iconAnchor and textAnchor style properties of an MGLSymbolStyleLayer to a data driven expression. This was useful if, for example, you wanted to use annotations that had a stem coming off of either the left or right hand side, like this:

Symbol Layer Stems

It was possible to make the anchor property dependent of a feature attribute that determined the "handed-ness" of the stem.

The corresponding SymbolLayer iconAnchor and textAnchor properties allow for only a constant value and won't accept and expression.

This is a regression in functionality that is very useful.

Style has no layers property

New Feature

In < Mapbox v10, style.layers exists.
Looks like Android can at least get a list of style layer identifiers: https://docs.mapbox.com/android/maps/api/10.0.0-beta.12/-mapbox%20-maps%20-android/com.mapbox.maps/-style/get-style-layers.html

Why

Stylelayers can be logically grouped by type or by content association. One way to do this is to access all the identifiers of all stylelayers, and select those whose identifiers satisfy some condition, like has a certain substring. Would need, tho, access to mapView.style.layers for that.

Was there a good reason for not providing style.layers in the new world?

Is it okay to release a new beta that doesn't even compile?

Environment

  • Xcode version: Version 12.4 (12D4e)
  • iOS version: 14.4
  • Devices affected: All
  • Maps SDK Version: 10.0.0-beta.15

Swift Compiler Error Group:

.../SourcePackages/checkouts/mapbox-maps-ios/Sources/MapboxMaps/Foundation/Extensions/Core/MapEvents.swift:50:28: Type 'MapEvents' has no member 'cameraChanged'

.../SourcePackages/checkouts/mapbox-maps-ios/Sources/MapboxMaps/Foundation/Extensions/Core/MapEvents.swift:86:34: Type 'MapEvents' has no member 'cameraChanged'

.../SourcePackages/checkouts/mapbox-maps-ios/Sources/MapboxMaps/Foundation/BaseMapView.swift:125:64: Extra argument 'pixelRatio' in call

.../SourcePackages/checkouts/mapbox-maps-ios/Sources/MapboxMaps/Foundation/BaseMapView.swift:119:52: Missing argument for parameter '__mapMode' in call

Warning Group:

Skipping duplicate build file in Copy Files build phase: .../SourcePackages/artifacts/MapboxCommon/MapboxCommon.xcframework/ios-arm64_i386_x86_64-simulator/MapboxCommon.framework

Run Examples tests fails: Process SceneKit document ... 34M_17.dae

https://app.circleci.com/pipelines/github/mapbox/mapbox-maps-ios/1114/workflows/2c53bb56-cfa9-4d98-9dad-952f0991d77a/jobs/7289/steps

CpResource /Users/distiller/project/Examples/Examples/All\ Examples/Sample\ Data/GradientLine.geojson /Users/distiller/project/build/Build/Products/Release-iphoneos/Examples.app/GradientLine.geojson (in target 'Examples' from project 'Examples')
    cd /Users/distiller/project/Examples
    builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -resolve-src-symlinks /Users/distiller/project/Examples/Examples/All\ Examples/Sample\ Data/GradientLine.geojson /Users/distiller/project/build/Build/Products/Release-iphoneos/Examples.app

** TEST BUILD FAILED **


The following build commands failed:
	Process SceneKit document /Users/distiller/Downloads/34M_17.dae

v10 zoom and rotation do not use correct axis

Environment

  • Xcode version: 12.3
  • iOS version: 14.3
  • Devices affected: all
  • Maps SDK Version: v10 beta 12

Observed behavior and steps to reproduce

  • When the user uses a pinch to zoom gesture, the map zooms in on the center of the view, not the center of the pinch gesture
  • When the user uses a pinch to rotate gesture, the map rotates about the center of the view, not the center of the pinch gesture

Expected behavior

  • Whenever a pinch gesture is used, the center of the pinch gesture is the axis of the map change.

Notes / preliminary analysis

NA

Additional links and references

NA

mapView.on(.cameraChanged) callback is called infinitely

Environment

  • Xcode version: Version 12.4 (12D4e)
  • iOS version: 14.4 (18D46)
  • Devices affected: iPhone 11 Pro simulator
  • Maps SDK Version: v10.0.0-beta.16

Observed behavior and steps to reproduce

mapView.on(.cameraChanged) callback is called on a loop even without any interaction with the map.
Steps to reproduce: add the following lines to LineAnnotationExample.swift:

        mapView.on(.cameraChanged) { event in
            print("Camera changed: \(event)")
        }

Console output:

Camera changed: <MBMEvent: 0x600002659660>
Camera changed: <MBMEvent: 0x6000026aebc0>
Camera changed: <MBMEvent: 0x60000265c6e0>
Camera changed: <MBMEvent: 0x6000026598e0>
Camera changed: <MBMEvent: 0x600002680020>
Camera changed: <MBMEvent: 0x6000027047a0>
Camera changed: <MBMEvent: 0x600002767400>
... and so on
bug.mov

Expected behavior

I expect that the callback is called only when the camera is actually changed

Notes / preliminary analysis

Additional links and references

'getSource` crashes or returns arbitrary, unconfigured `Source`

Environment

  • Xcode version: 12.4
  • iOS version: 14.4
  • Devices affected: all
  • Maps SDK Version: beta.13

Observed behavior and steps to reproduce

Stylesheet contains a source with identifier "aerial". Asking for the source from style results in a crash.

mapView.on(.styleLoadingFinished) { [weak self] event in
    let result = self.mapView.style.getSource(identifier: "aerial", type: RasterSource.self) // CRASH
    ...
}
Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=com.mapbox.bindgen Code=-2 "*** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: bounds)" UserInfo={NSUnderlyingErrorKey=*** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: bounds), NSLocalizedFailureReason=*** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: bounds)}: file MapboxMaps/Style.swift, line 271

Style.swift Line 271:
let sourceProps = try! self.styleManager.getStyleSourceProperties(forSourceId: identifier)

Alternatively, do not do the line above, and after on(.mapLoadingFinished) add a PointAnnotation. This triggers two events: .sourceChanged and .styleFullyLoaded. The identifier of the source that changed is com.mapbox.AnnotationManager.DefaultSourceLayer. So do:


func handle<T>(result: Result<T, SourceError>) {
    switch result {
    case .success(let source):
        log("source is \(source)")
    case .failure(let error):
        log("getSource failed: \(error)")
    }
}

let identifier: String = "com.mapbox.AnnotationManager.DefaultSourceLayer"
handle(result: style.getSource(identifier: identifier, type: VectorSource.self))
handle(result: style.getSource(identifier: identifier, type: RasterSource.self))
handle(result: style.getSource(identifier: identifier, type: RasterDemSource.self))
handle(result: style.getSource(identifier: identifier, type: GeoJSONSource.self))
handle(result: style.getSource(identifier: identifier, type: ImageSource.self))
handle(result: style.getSource(identifier: identifier, type: ModelSource.self))

Output:

[style] source is VectorSource(type: MapboxMaps.SourceType.geoJson, url: nil, tiles: nil, bounds: nil, scheme: nil, minzoom: nil, maxzoom: nil, attribution: nil, volatile: nil, prefetchZoomDelta: nil, minimumTileUpdateInterval: nil, maxOverscaleFactorForParentTiles: nil)
[style] source is RasterSource(type: MapboxMaps.SourceType.geoJson, url: nil, tiles: nil, bounds: nil, minzoom: nil, maxzoom: nil, tileSize: nil, scheme: nil, attribution: nil, volatile: nil, prefetchZoomDelta: nil, minimumTileUpdateInterval: nil, maxOverscaleFactorForParentTiles: nil)
[style] source is RasterDemSource(type: MapboxMaps.SourceType.geoJson, url: nil, tiles: nil, bounds: nil, minzoom: nil, maxzoom: nil, tileSize: nil, attribution: nil, encoding: nil, volatile: nil, prefetchZoomDelta: nil, minimumTileUpdateInterval: nil, maxOverscaleFactorForParentTiles: nil)
[style] source is GeoJSONSource(type: MapboxMaps.SourceType.geoJson, data: nil, maxzoom: nil, attribution: nil, buffer: nil, tolerance: nil, cluster: nil, clusterRadius: nil, clusterMaxZoom: nil, clusterProperties: nil, lineMetrics: nil, prefetchZoomDelta: nil)
[style] source is ImageSource(type: MapboxMaps.SourceType.geoJson, url: nil, coordinates: nil, prefetchZoomDelta: nil)
[style] source is ModelSource(type: MapboxMaps.SourceType.geoJson, models: nil)

Expected behavior

No crash in the first case. A GeoJsonSource in the latter case.

Notes / preliminary analysis

Discovered this while trying to access the source for PointAnnotations so as to configure the way the source clusters.

The documentation states: "new approach to annotations is that they are all powered internally by the use of​ ​style layers​.". I do not know how to access these stylelayers, but I noticed that after the .onSourceChange above, mapView.style.styleManager.getStyleSources() returns an array in which the last element has the "com.mapbox.AnnotationManager.DefaultSourceLayer" identifier, and type is geojson, so I tried to update the cluster property of this source using updateSourceProperty(id:property:value:), but couldn't figure out what the value of value argument should be. So then I thought to get the source, and then discovered that I got one with all internal properties set to nil, so I tried a different type of Source, and discovered that getSource never fails when asked for one with that identifier, it returns any Source type you ask for, just with nil properties. So then I thought to get a different source, one that I knew was added by the stylesheet, but got the crash.

Additional links and references

Style images do not match screen resolution

Style.setStyleImage(image:with:sdf:stretchX:stretchY:scale:imageContent:) unconditionally adds the image to the style at a resolution of 3×, even if the map is being displayed on a 1× or 2× screen:

let expected = try! styleManager.addStyleImage(forImageId: identifier,
scale: 3.0,
image: mbxImage,
sdf: sdf,
stretchX: stretchX,
stretchY: stretchY,
content: imageContent)

This presumably causes images to either look blurry or have the wrong size on some common devices.

/cc @mapbox/maps-ios @MaximAlien

Supporting Apple Silicon

Apple Silicon

Supporting Apple Silicon is an important goal for the Maps SDK. This means enabling Apple Silicon M1 Macs to be used as both development machines as well as deployment targets, allowing developers to build new and unique experiences for the desktop.

Now that the SDK and our dependencies support XCFrameworks and Swift Package Manager, we can address the following remaining tasks:

  • Ensure all dependencies contain arm64 simulator slices
  • Migrate SDK development from using Carthage to SPM internally.
  • Remove all existing Xcode 12 / arm64 simulator hacks from makefiles and Xcode configurations.
  • Update Cocoapods podspecs similarly

These unblock us from being able to provide Apple Silicon support via XCFrameworks, and to support Xcode 12.3+ without hacks.

In 2D and 3D, user location puck is hidden by PointAnnotations

Environment

  • Xcode version: 12.4
  • iOS version: 14.4
  • Devices affected: any
  • Maps SDK Version: beta.13

Observed behavior and steps to reproduce

Add a PointAnnotation at a location, then physically have the device near that location but not exactly coincident.

When zoomed out, the user location puck is not drawn.
goOHy

When zoomed in to a point that the location puck appears, pitch the map and pinch to rotate the map 360 degrees about the PointAnnotation and the user location puck, and the PointAnnotation will always appear in front of the user location puck, which is not possible because there exists 180 degrees where the puck is closer to the camera than the annotation.
WcLOc
UwPjG
gIi9k
BYSJH

Expected behavior

In Mapbox SDK versions before v10, the puck always appears on top of annotations.
The user location puck should not be included in clustering.

Notes / preliminary analysis

Additional links and references

.cameraDidChange and .cameraWillChange fire multiple events like .cameraIsChanging

Environment

  • Xcode version: 12.4
  • iOS version: 14.4
  • Devices affected:
  • Maps SDK Version: beta.13

Observed behavior and steps to reproduce

.cameraDidChange and .cameraWillChange behave like one would expect .cameraIsChanging where the event is fired multiple times.

cameraDidChange.mov

Expected behavior

.cameraDidChange and .cameraWillChange fire one time.

Is there a different for users to detect when a camera animation starts and stops? I know that setCamera has a completion handler but is this the only way?

Notes / preliminary analysis

Additional links and references

Missing MGLNetworkConfiguration

New Feature

The old version of the Mapbox iOS SDK had MGLNetworkConfiguration. There I could set a delegate and therefore intercept API calls. We need something similar again for the new version.

Why

We used this feature, to implement our own Offline-Map handling. The problem with the default offline-map handling for us was that it wasn't 1. working in the background, 2. very CPU intensive and 3. quite slow.
That's why we went ahead and pre-packed regions for the user. By intercepting the network calls, we were able to provide those tiles ourselves.
We use the same on Android and iOS, and the Android version seems to have even improved support for that:
https://docs.mapbox.com/android/beta/maps/guides/migrate-to-v10/#example-replace-modular-http-stack

For us this is an absolute must as we already build our whole infrastructure on that.

Camera jumps to different locations when panning

Environment

  • Xcode version: 12
  • iOS version: 14
  • Devices affected: All
  • Maps SDK Version: v10.0.0-beta.12

Observed behavior and steps to reproduce

The map camera will sometimes jump around to a new location when attempting to pan on a map. I believe this happens more often (or maybe even exclusively?) when there is a non-zero pitch value on the map camera.

Expected behavior

The map camera should remain in a nearby location when panning across the map.

Additional links and references

Videos:

RPReplay_Final1611784725.MOV
RPReplay_Final1611784620.MOV

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.