maplibre / maplibre-navigation-ios

MapLibre Navigation SDK for iOS
Other
36 stars 29 forks source link

Add proper support for non-Mapbox styles #2

Open ianthetechie opened 1 year ago

ianthetechie commented 1 year ago

Motivation

This is MapLibre navigation, not Mapbox Navigation anymore. As such, I propose that we support, at a minimum, OpenMapTiles-derived tiles, but a general solution seems quite possible. Right now there are numerous points at which Mapbox styles are hord-coded, and we should generally avoid this, or any similar sort of dependence on a single tile provider.

Design

It a minimum, we will need to touch MGLVectorTileSource.swift, NavigationMapView.swift, and RouteMapViewController.swift, as these all have a hard-coded dependency on the Mapbox Streets style. My understanding is that these are primarily for picking up road labels, but they may be used for more.

MGLVectorTileSource is the root of the problem, since it is so mapbox-specific. We essentially have two options: add more variants (ex: OMT), or find a different, more general solution for picking out the correct source and layer.

Beyond this, I am unfortunately not able to propose a design off the top of my head. I would welcome input from others with more familiarity.

Mock-Up

N/A

Concepts

TBD

Implementation

TBD if we go for the more general option. Fairly straightforward to add a case for isOpenMapTiles or something, though I think we would probably have to make a heuristic guess at whether the style truly is OpenMapTiles-compatible. Perhaps hasTransportationName would be a more useful approach?

Feedback welcome; all of my specific suggestions are secondary to the overall goal of properly supporting non-Mapbox styles. I'm happy to contribute code after some discussion with the community.

michaelkirk commented 4 months ago

Currently there's no way (as far as I can tell) to specify a styleURL for NavigationViewController.

I'm wondering if that's the same underlying issue as here, or if I should open a new issue.

NavigationViewController gets its MLNMapView via (self.mapViewController.view as NavigationView).mapView

class NavigationView: UIView {
  ...
  lazy var mapView: NavigationMapView = { // Subclass of MLNMapView
       let map: NavigationMapView = .forAutoLayout(frame: self.bounds) // not given a styleURL
       map.delegate = self.delegate
       map.navigationMapDelegate = self.delegate
       map.courseTrackingDelegate = self.delegate
       map.showsUserLocation = true
       return map
  }()
}