Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set max zoom on shape sources #729

Merged
merged 1 commit into from
Oct 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions MapboxNavigation/NavigationMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ let routeLineWidthAtZoomLevels: [Int: MGLStyleValue<NSNumber>] = [
22: MGLStyleValue(rawValue: 28)
]

let sourceOptions: [MGLShapeSourceOption: Any] = [.maximumZoomLevel: 16]

/**
`NavigationMapView` is a subclass of `MGLMapView` with convenience functions for adding `Route` lines to a map.
*/
Expand Down Expand Up @@ -341,8 +343,8 @@ open class NavigationMapView: MGLMapView {
source.shape = polyline
sourceSimplified.shape = polylineSimplified
} else {
let lineSource = MGLShapeSource(identifier: sourceIdentifier, shape: polyline, options: nil)
let lineCasingSource = MGLShapeSource(identifier: sourceCasingIdentifier, shape: polylineSimplified, options: nil)
let lineSource = MGLShapeSource(identifier: sourceIdentifier, shape: polyline, options: sourceOptions)
let lineCasingSource = MGLShapeSource(identifier: sourceCasingIdentifier, shape: polylineSimplified, options: sourceOptions)
style.addSource(lineSource)
style.addSource(lineCasingSource)

Expand Down Expand Up @@ -400,7 +402,7 @@ open class NavigationMapView: MGLMapView {
if let waypointSource = style.source(withIdentifier: waypointSourceIdentifier) as? MGLShapeSource {
waypointSource.shape = source
} else {
let sourceShape = MGLShapeSource(identifier: waypointSourceIdentifier, shape: source, options: nil)
let sourceShape = MGLShapeSource(identifier: waypointSourceIdentifier, shape: source, options: sourceOptions)
style.addSource(sourceShape)

let circles = navigationMapDelegate?.navigationMapView?(self, waypointStyleLayerWithIdentifier: waypointCircleIdentifier, source: sourceShape) ?? routeWaypointCircleStyleLayer(identifier: waypointCircleIdentifier, source: sourceShape)
Expand Down Expand Up @@ -638,9 +640,9 @@ open class NavigationMapView: MGLMapView {
let cap = NSValue(mglLineCap: .butt)
let join = NSValue(mglLineJoin: .round)

let arrowSourceStroke = MGLShapeSource(identifier: arrowSourceStrokeIdentifier, shape: arrowStrokeShape, options: nil)
let arrowSourceStroke = MGLShapeSource(identifier: arrowSourceStrokeIdentifier, shape: arrowStrokeShape, options: sourceOptions)
let arrowStroke = MGLLineStyleLayer(identifier: arrowLayerStrokeIdentifier, source: arrowSourceStroke)
let arrowSource = MGLShapeSource(identifier: arrowSourceIdentifier, shape: arrowShape, options: nil)
let arrowSource = MGLShapeSource(identifier: arrowSourceIdentifier, shape: arrowShape, options: sourceOptions)
let arrow = MGLLineStyleLayer(identifier: arrowLayerIdentifier, source: arrowSource)

if let source = style.source(withIdentifier: arrowSourceIdentifier) as? MGLShapeSource {
Expand Down Expand Up @@ -677,7 +679,7 @@ open class NavigationMapView: MGLMapView {
// Arrow symbol
let point = MGLPointFeature()
point.coordinate = shaftStrokeCoordinates.last!
let arrowSymbolSource = MGLShapeSource(identifier: arrowSymbolSourceIdentifier, features: [point], options: nil)
let arrowSymbolSource = MGLShapeSource(identifier: arrowSymbolSourceIdentifier, features: [point], options: sourceOptions)

if let source = style.source(withIdentifier: arrowSymbolSourceIdentifier) as? MGLShapeSource {
source.shape = arrowSymbolSource.shape
Expand Down