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

Rename map IDs to tileset IDs #100

Merged
merged 1 commit into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
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
26 changes: 13 additions & 13 deletions Sources/MapboxStatic/ClassicSnapshotOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import CoreLocation


/**
A structure that determines what a snapshot depicts and how it is formatted. A classic snapshot is made by compositing one or more [tile sets](https://www.mapbox.com/help/define-tileset/) with optional overlays using the [Legacy Static Images API](https://docs.mapbox.com/api/legacy/static-classic).
A structure that determines what a snapshot depicts and how it is formatted. A classic snapshot is made by compositing one or more [tile sets](https://docs.mapbox.com/help/glossary/tileset/) with optional overlays using the [Legacy Static Images API](https://docs.mapbox.com/api/legacy/static-classic).

Typically, you use a `ClassicSnapshotOptions` object to generate a snapshot of a [raster tile set](https://www.mapbox.com/help/define-tileset/#raster-tilesets). If you use `ClassicSnapshotOptions` to display a [vector tile set](https://www.mapbox.com/help/define-tileset/#vector-tilesets), the snapshot image will depict a wireframe representation of the tile set. To generate a static, styled image of a vector tile set, use a `SnapshotOptions` object.
Typically, you use a `ClassicSnapshotOptions` object to generate a snapshot of a [raster tile set](https://docs.mapbox.com/help/glossary/tileset/#raster-tilesets). If you use `ClassicSnapshotOptions` to display a [vector tile set](https://docs.mapbox.com/help/glossary/tileset/#vector-tilesets), the snapshot image will depict a wireframe representation of the tile set. To generate a static, styled image of a vector tile set, use a `SnapshotOptions` object.
*/
@objc(MBClassicSnapshotOptions)
open class ClassicSnapshotOptions: NSObject, SnapshotOptionsProtocol {
Expand Down Expand Up @@ -66,11 +66,11 @@ open class ClassicSnapshotOptions: NSObject, SnapshotOptionsProtocol {
// MARK: Configuring the Map Data

/**
An array of [map identifiers](https://www.mapbox.com/help/define-map-id/) of the form `username.id`, identifying the [tile sets](https://www.mapbox.com/help/define-tileset/) to display in the snapshot. This array may not be empty.
An array of [tile set identifiers](https://docs.mapbox.com/help/glossary/tileset-id/) of the form `username.id`, identifying the [tile sets](https://docs.mapbox.com/help/glossary/tileset/) to display in the snapshot. This array may not be empty.

The order of the map identifiers in the array reflects their visible order in the snapshot, with the tile set identified at index 0 being the backmost tile set.
The order of the tile set identifiers in the array reflects their visible order in the snapshot, with the tile set identified at index 0 being the backmost tile set.
*/
@objc open var mapIdentifiers: [String]
@objc open var tileSetIdentifiers: [String]

/**
An array of overlays to draw atop the map.
Expand Down Expand Up @@ -145,24 +145,24 @@ open class ClassicSnapshotOptions: NSObject, SnapshotOptionsProtocol {

After initializing a snapshot options instance with this initializer, set the `overlays` property to specify the overlays to fit the snapshot to.

- parameter mapIdentifiers: An array of [map identifiers](https://www.mapbox.com/help/define-map-id/) of the form `username.id`, identifying the [tile sets](https://www.mapbox.com/help/define-tileset/) to display in the snapshot. This array may not be empty.
- parameter tileSetIdentifiers: An array of [tile set identifiers](https://docs.mapbox.com/help/glossary/tileset-id/) of the form `username.id`, identifying the [tile sets](https://docs.mapbox.com/help/glossary/tileset/) to display in the snapshot. This array may not be empty.
- parameter size: The logical size of the image to output, measured in points.
*/
@objc public init(mapIdentifiers: [String], size: CGSize) {
self.mapIdentifiers = mapIdentifiers
@objc public init(tileSetIdentifiers: [String], size: CGSize) {
self.tileSetIdentifiers = tileSetIdentifiers
self.size = size
}

/**
Initializes a snapshot options instance that results in a snapshot centered at the given geographical coordinate and showing the given zoom level.

- parameter mapIdentifiers: An array of [map identifiers](https://www.mapbox.com/help/define-map-id/) of the form `username.id`, identifying the [tile sets](https://www.mapbox.com/help/define-tileset/) to display in the snapshot. This array may not be empty.
- parameter tileSetIdentifiers: An array of [tile set identifiers](https://docs.mapbox.com/help/glossary/tileset-id/) of the form `username.id`, identifying the [tile sets](https://docs.mapbox.com/help/glossary/tileset/) to display in the snapshot. This array may not be empty.
- parameter centerCoordinate: The geographic coordinate at the center of the snapshot.
- parameter zoomLevel: The zoom level of the snapshot.
- parameter size: The logical size of the image to output, measured in points.
*/
@objc public init(mapIdentifiers: [String], centerCoordinate: CLLocationCoordinate2D, zoomLevel: Int, size: CGSize) {
self.mapIdentifiers = mapIdentifiers
@objc public init(tileSetIdentifiers: [String], centerCoordinate: CLLocationCoordinate2D, zoomLevel: Int, size: CGSize) {
self.tileSetIdentifiers = tileSetIdentifiers
self.centerCoordinate = centerCoordinate
self.zoomLevel = zoomLevel
self.size = size
Expand All @@ -174,8 +174,8 @@ open class ClassicSnapshotOptions: NSObject, SnapshotOptionsProtocol {
- returns: An HTTP URL path.
*/
@objc open var path: String {
assert(!mapIdentifiers.isEmpty, "At least one map identifier must be specified.")
let tileSetComponent = mapIdentifiers.joined(separator: ",")
assert(!tileSetIdentifiers.isEmpty, "At least one tile set identifier must be specified.")
let tileSetComponent = tileSetIdentifiers.joined(separator: ",")

let position: String
if let centerCoordinate = centerCoordinate {
Expand Down
2 changes: 1 addition & 1 deletion Sources/MapboxStatic/MarkerOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ open class MarkerOptions: MarkerImage, SnapshotOptionsProtocol {
Initializes a marker options instance that results in a red marker with a Maki icon.

- parameter size: The size of the marker.
- parameter iconName: The name of a [Maki](https://www.mapbox.com/maki-icons/) v0.5.0 icon to place atop the pin.
- parameter iconName: The name of a [Maki](https://labs.mapbox.com/maki-icons/) v0.5.0 icon to place atop the pin.
*/
public convenience init(size: Size = .small, iconName: String) {
self.init(size: size, label: .iconName(iconName))
Expand Down
16 changes: 8 additions & 8 deletions Sources/MapboxStatic/Overlay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ open class MarkerImage: NSObject {
/// A number from 0 through 99.
case number(Int)
/**
The name of a [Maki](https://www.mapbox.com/maki-icons/) icon.
The name of a [Maki](https://labs.mapbox.com/maki-icons/) icon.

The Static Images API uses Maki v4.0.0. See valid values at the [Maki](https://www.mapbox.com/maki-icons/) website. The Legacy Static Images API uses Maki v0.5.0. Valid values for classic snapshots are identified by the `icon` values in [this JSON file](https://github.com/mapbox/maki/blob/v0.5.0/_includes/maki.json).
The Static Images API uses Maki v4.0.0. See valid values at the [Maki](https://labs.mapbox.com/maki-icons/) website. The Legacy Static Images API uses Maki v0.5.0. Valid values for classic snapshots are identified by the `icon` values in [this JSON file](https://github.com/mapbox/maki/blob/v0.5.0/_includes/maki.json).
*/
case iconName(String)

Expand Down Expand Up @@ -184,15 +184,15 @@ open class Marker: MarkerImage, Point {
}

/**
Initializes a red marker with a [Maki](https://www.mapbox.com/maki-icons/) icon.
Initializes a red marker with a [Maki](https://labs.mapbox.com/maki-icons/) icon.

The Maki icon set is [open source](https://github.com/mapbox/maki/) and [dedicated to the public domain](https://creativecommons.org/publicdomain/zero/1.0/).

The Static Images API uses Maki v4.0.0. See valid values at the [Maki](https://www.mapbox.com/maki-icons/) website. The Legacy Static Images API uses Maki v0.5.0. Valid values for classic snapshots are identified by the `icon` values in [this JSON file](https://github.com/mapbox/maki/blob/v0.5.0/_includes/maki.json).
The Static Images API uses Maki v4.0.0. See valid values at the [Maki](https://labs.mapbox.com/maki-icons/) website. The Legacy Static Images API uses Maki v0.5.0. Valid values for classic snapshots are identified by the `icon` values in [this JSON file](https://github.com/mapbox/maki/blob/v0.5.0/_includes/maki.json).

- parameter coordinate: The geographic coordinate to place the marker at.
- parameter size: The size of the marker.
- parameter iconName: The name of a [Maki](https://www.mapbox.com/maki-icons/) icon to place atop the pin.
- parameter iconName: The name of a [Maki](https://labs.mapbox.com/maki-icons/) icon to place atop the pin.
*/
@objc public convenience init(coordinate: CLLocationCoordinate2D,
size: Size = .small,
Expand Down Expand Up @@ -247,7 +247,7 @@ open class CustomMarker: NSObject, Overlay {
}

/**
A geographic object in [GeoJSON](https://www.mapbox.com/help/define-geojson/) format.
A geographic object in [GeoJSON](https://docs.mapbox.com/help/glossary/geojson/) format.

GeoJSON features may be styled according to the [simplestyle specification](https://github.com/mapbox/simplestyle-spec).
*/
Expand All @@ -262,7 +262,7 @@ open class GeoJSON: NSObject, Overlay {
}

/**
Initializes a [GeoJSON](https://www.mapbox.com/help/define-geojson/) overlay with the given GeoJSON object.
Initializes a [GeoJSON](https://docs.mapbox.com/help/glossary/geojson/) overlay with the given GeoJSON object.

- parameter object: A valid GeoJSON object.
- returns: A GeoJSON overlay, or `nil` if the given object is not a valid JSON object. This initializer does not check whether the object is valid GeoJSON, but invalid GeoJSON will cause the request to fail.
Expand All @@ -273,7 +273,7 @@ open class GeoJSON: NSObject, Overlay {
}

/**
Initializes a [GeoJSON](https://www.mapbox.com/help/define-geojson/) overlay with the given string representation of a GeoJSON object.
Initializes a [GeoJSON](https://docs.mapbox.com/help/glossary/geojson/) overlay with the given string representation of a GeoJSON object.

This initializer does not check whether the object is valid JSON or GeoJSON, but invalid JSON or GeoJSON will cause the request to fail. To perform basic JSON validation (but not GeoJSON validation), use the `init(object:)` initializer.

Expand Down
8 changes: 4 additions & 4 deletions Sources/MapboxStatic/Snapshot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public protocol SnapshotOptionsProtocol: NSObjectProtocol {
/**
A `Snapshot` instance represents a static snapshot of a map with optional overlays. With a snapshot instance, you can synchronously or asynchronously generate an image based on the options you provide via an HTTP request, or you can get the URL used to make this request. The image is obtained on demand from the [Mapbox Static Images API](https://docs.mapbox.com/api/maps/#static-images) or the [Legacy Static Images API](https://docs.mapbox.com/api/legacy/static-classic/#retrieve-a-static-map-image), depending on whether you use a `SnapshotOptions` object or a `ClassicSnapshotOptions` object.

The snapshot image can be used in an image view (`UIImage` on iOS and tvOS, `NSImage` on macOS, `WKImage` on watchOS). The image does not respond to user gestures. To add interactivity, use the [Mapbox Maps SDK for iOS](https://www.mapbox.com/ios-sdk/) or the [Mapbox Maps SDK for macOS](https://github.com/mapbox/mapbox-gl-native/tree/master/platform/macos/), which can optionally display raster tiles. If you are already using the map SDKs for iOS or macOS, use the `MGLMapSnapshotter` object instead of this class to take advantage of caching and offline packs.
The snapshot image can be used in an image view (`UIImage` on iOS and tvOS, `NSImage` on macOS, `WKImage` on watchOS). The image does not respond to user gestures. To add interactivity, use the [Mapbox Maps SDK for iOS](https://docs.mapbox.com/ios/maps/) or the [Mapbox Maps SDK for macOS](https://mapbox.github.io/mapbox-gl-native/macos/), which can optionally display raster tiles. If you are already using the map SDKs for iOS or macOS, use the `MGLMapSnapshotter` object instead of this class to take advantage of caching and offline packs.
*/
@objc(MBSnapshot)
open class Snapshot: NSObject {
Expand Down Expand Up @@ -103,12 +103,12 @@ open class Snapshot: NSObject {
Initializes a newly created snapshot instance with the given options and an optional access token and host.

- parameter options: Options that determine the contents and format of the output image.
- parameter accessToken: A Mapbox [access token](https://www.mapbox.com/help/define-access-token/). If an access token is not specified when initializing the snapshot object, it should be specified in the `MGLMapboxAccessToken` key in the main application bundle’s Info.plist.
- parameter accessToken: A Mapbox [access token](https://docs.mapbox.com/help/glossary/access-token/). If an access token is not specified when initializing the snapshot object, it should be specified in the `MGLMapboxAccessToken` key in the main application bundle’s Info.plist.
- parameter host: An optional hostname to the server API. The official Mapbox API endpoint is used by default.
*/
@objc public init(options: SnapshotOptionsProtocol, accessToken: String?, host: String?) {
let accessToken = accessToken ?? defaultAccessToken
assert(accessToken != nil && !accessToken!.isEmpty, "A Mapbox access token is required. Go to <https://www.mapbox.com/studio/account/tokens/>. In Info.plist, set the MGLMapboxAccessToken key to your access token, or use the Snapshot(options:accessToken:host:) initializer.")
assert(accessToken != nil && !accessToken!.isEmpty, "A Mapbox access token is required. Go to <https://account.mapbox.com/access-tokens/>. In Info.plist, set the MGLMapboxAccessToken key to your access token, or use the Snapshot(options:accessToken:host:) initializer.")

self.options = options
self.accessToken = accessToken!
Expand All @@ -125,7 +125,7 @@ open class Snapshot: NSObject {
The snapshot instance sends requests to the official Mapbox API endpoint.

- parameter options: Options that determine the contents and format of the output image.
- parameter accessToken: A Mapbox [access token](https://www.mapbox.com/help/define-access-token/). If an access token is not specified when initializing the snapshot object, it should be specified in the `MGLMapboxAccessToken` key in the main application bundle’s Info.plist.
- parameter accessToken: A Mapbox [access token](https://docs.mapbox.com/help/glossary/access-token/). If an access token is not specified when initializing the snapshot object, it should be specified in the `MGLMapboxAccessToken` key in the main application bundle’s Info.plist.
*/
@objc public convenience init(options: SnapshotOptionsProtocol, accessToken: String?) {
self.init(options: options, accessToken: accessToken, host: nil)
Expand Down
Loading