Mapbox Maps SDK for macOS
Put interactive, scalable world maps into your native Cocoa application with the open-source Mapbox Maps SDK for macOS.
- Mapbox-curated map styles and OpenStreetMap-based vector tiles make it easy to get started.
- Customize every aspect of the map’s appearance in code or visually using Mapbox Studio.
- High-performance OpenGL rendering and multitouch gestures keep your users happy.
- A well-designed, fully documented API helps you stay productive.
- Develop across multiple platforms, including iOS, using the same styles and similar APIs.

The Mapbox Maps SDK for macOS is compatible with macOS 10.11.0 and above for Cocoa applications developed in Objective-C, Swift, Interface Builder, or AppleScript. For hybrid applications, consider Mapbox GL JS.
Installation
There are three ways to install the Mapbox Maps SDK for macOS:
Manually
Download the latest Mapbox Maps SDK for macOS release from GitHub – look for a release that begins with “macos-”.
Open the project editor, select your application target, then go to the General tab. Drag Mapbox.framework into the “Embedded Binaries” section. (Don’t drag it into the “Linked Frameworks and Libraries” section; Xcode will add it there automatically.) In the sheet that appears, make sure “Copy items if needed” is checked, then click Finish.
Via Carthage
The Mapbox Maps SDK for macOS is a binary-only dependency, so you’ll need Carthage 0.19 or above. In your Cartfile, specify this dependency (plus an optional version requirement):
binary "https://mapbox.github.io/mapbox-gl-native/macos/Mapbox-macOS-SDK.json"
After running carthage update, you’ll find Mapbox.framework in the Carthage/Build/ folder. Follow these instructions to integrate it into your project.
Via CocoaPods
Create a Podfile with the following specification:
platform :osx, '10.11'
target 'TargetNameForYourApp' do
pod 'Mapbox-macOS-SDK', '~> x.y'
end
where x.y is the current version. In Terminal, run pod install.
Usage
Mapbox vector tiles require a Mapbox account and API access token. In the project editor, select the application target, then go to the Info tab. Under the “Custom macOS Application Target Properties” section, set MGLMapboxAccessToken to your access token. You can obtain an access token from the Mapbox account page.
Then, in a storyboard or XIB:
- Add a view to your view controller or window. (Drag Custom View from the Object library to the View Controller scene on the Interface Builder canvas. In a XIB, drag it instead to the window on the canvas.)
- In the Identity inspector, set the view’s custom class to
MGLMapView. - MGLMapView needs to be layer-backed:
- You can make the window layer-backed by selecting the window and checking Full Size Content View in the Attributes inspector. This allows the map view to underlap the title bar and toolbar.
- Alternatively, if you don’t want the entire window to be layer-backed, you can make just the map view layer-backed by selecting it and checking its entry under the View Effects inspector’s Core Animation Layer section.
- Add a map feedback item to your Help menu. (Drag Menu Item from the Object library into Main Menu ‣ Help ‣ Menu.) Title it “Improve This Map” or similar, and connect it to the
giveFeedback:action of First Responder.
If you need to manipulate the map view programmatically:
- Switch to the Assistant Editor.
- Import the
Mapboxmodule. - Connect the map view to a new outlet in your view controller class. (Control-drag from the map view in Interface Builder to a valid location in your view controller implementation.) The resulting outlet declaration should look something like this:
// ViewController.m
@import Mapbox;
@interface ViewController : NSViewController
@property (strong) IBOutlet MGLMapView *mapView;
@end
// ViewController.swift
import Mapbox
class ViewController: NSViewController {
@IBOutlet var mapView: MGLMapView!
}
-- AppDelegate.applescript
script AppDelegate
property parent : class "NSObject"
property theMapView : missing value
end script
Full API documentation is included in this package, within the documentation folder, and online. The Mapbox Maps SDK for iOS has API documentation and online examples that apply to the Mapbox Maps SDK for macOS with few differences, mostly around unimplemented features like user location tracking.
Mapbox does not officially support the macOS SDK to the same extent as the iOS SDK; however, bug reports and pull requests are certainly welcome.
Changes in version 0.15.0
Styles and rendering
- Added the
-[MGLMapViewDelegate mapView:shouldRemoveStyleImage:]method for optimizing style image caching. (#14769) - Added the
imageexpression function for converting an image name into a style image. Use this function in expressions in style JSON or with theMGL_FUNCTION()syntax in anNSExpressionformat string. Image expressions are compatible with themgl_attributed:expression function andMGLAttributedExpressionclasses for embedding icons inline in text labels. (#15877, #15937) - The
INandCONTAINSpredicate operators can now test whether a string is a substring of another string or whether the evaluated feature (SELF) lies within a givenMGLShapeorMGLFeature. (#183, #184) - Added the
MGLSymbolStyleLayer.textWritingModeslayout property. This property can be set toMGLTextWritingModeHorizontalorMGLTextWritingModeVertical. (#14932) - Added the
MGLLineStyleLayer.lineSortKeyandMGLFillStyleLayer.fillSortKeyproperties. (#179) - The
MGLIdeographicFontFamilyNameInfo.plist key now also accepts an array of font family names, to customize font fallback behavior. It can also be set to a Boolean value ofNOto force the SDK to typeset CJK characters in a remote font specified byMGLSymbolStyleLayer.textFontNames. (#14862) - The
MGLSymbolStyleLayer.iconTextFitproperty now respects the cap insets of any nine-part stretchable image passed into the-[MGLStyle setImage:forName:]method. You can define the stretchable area in Xcode’s asset catalog or by setting theNSImage.capInsetsproperty. (#182) - The
-[MGLStyle localizeLabelsIntoLocale:]and-[NSExpression mgl_expressionLocalizedIntoLocale:]methods can now localize text into Traditional Chinese and Vietnamese. (#173) - Fixed crashes triggered when
MGLSourceandMGLStyleLayerobjects are accessed after having been invalidated after a style change. (#15539) - Fixed an issue where fill extrusion layers would be incorrectly rendered above other layers. (#15065)
- Fixed rendering and collision detection issues with using
MGLSymbolStyleLayer.textVariableAnchorandMGLSymbolStyleLayer.iconTextFitproperties on the same layer. (#15367) - Fixed symbol overlap when zooming out quickly. (#15416)
- Fixed an issue where non-template images would draw as template images when used in the same style layer. (#15456)
- Fixed an issue where the collision boxes for symbols would not be updated when
MGLSymbolStyleLayer.textTranslationorMGLSymbolStyleLayer.iconTranslationwere used. (#15467) - Fixed an issue that caused
MGLTileSourceOptionMaximumZoomLevelto be ignored when settingMGLTileSource.configurationURL. (#15581) - Fixed an issue where
MGLSymbolStyleLayer.symbolSortKeycould sort text and icons incorrectly. (#16023) - Fixed an issue where style layers backed by a shape source could flicker when transitioning between styles. (#15907, #15941)
- Improved the performance of loading a style that has many style images. (#16187)
- Updated “map ID” to the more accurate term “tileset ID” in documentation; updated “style’s Map ID” to the more accurate term “style URL”. (#15116)
Camera
- Setting
MGLMapView.contentInsetnow moves the map’s focal point to the center of the content frame after insetting. (#14664) - The
-[MGLMapView setCamera:withDuration:animationTimingFunction:edgePadding:completionHandler:]method now adds the current value of theMGLMapView.contentInsetsproperty to theedgePaddingparameter. (#14813) - Added variants of multiple animated
MGLMapViewmethods that accept completion handlers (#14381): - Added the
MGLMapView.minimumPitchandMGLMapView.maximumPitchproperties to further limit how much the user or your code can tilt the map. (#208) - Fixed an issue where it was possible to set the map’s content insets then tilt the map enough to see the horizon, causing performance issues. (#15195)
- Fixed an issue where animated camera transitions zoomed in or out too dramatically. (#15281)
- Improved performance when continuously animating a tilted map. (#16287)
Feature querying
- Fixed an issue where
-[MGLMapView visibleFeaturesInRect:]and-[MGLShapeSource featuresMatchingPredicate:]omitted some features from the return value. (#14884) - Fixed an issue where
-[MGLMapView visibleFeaturesInRect:]and-[MGLShapeSource featuresMatchingPredicate:]could return incorrect coordinates at zoom levels 20 and higher. (#15560) - Improved feature querying performance. (#14930)
Snapshots
- Added an
-[MGLMapSnapshotter startWithOverlayHandler:completionHandler:]method to provide the snapshot’s currentCGContextin order to perform custom drawing onMGLMapSnapshotobjects. (#15530) - Added the
MGLMapSnapshotter.delegateproperty andMGLMapSnapshotterDelegateprotocol for customizing the style before taking a snapshot. (#235) - You no longer need to explicitly capture the
MGLMapSnapshotterobject in the completion handler that you specify in-[MGLMapSnapshotter startWithCompletionHandler:]. Even if you declare the snapshotter locally without holding a strong reference to it, the snapshotter is only deallocated after the completion handler finishes, and the completion handler generally receives a valid snapshot. (#210) - The
-[MGLMapSnapshotter cancel]method no longer calls the completion handler passed into-[MGLMapSnapshotter startWithCompletionHandler:]. (#210) - Fixed an issue where the
MGLMapSnapshotter.loadingproperty always returnedNO, even while loading a snapshot. (#210)
Networking and storage
- Ideographic glyphs from Chinese, Japanese, and Korean are no longer downloaded by default as part of offline packs; they are instead rendered on-device, saving bandwidth and storage while improving performance. (#14176)
- Downloaded offline packs no longer reduce the storage space available for ambient caching of tiles and other resources. (#15622)
- Added the
MGLMapView.prefetchesTilesproperty to configure lower-resolution tile prefetching behavior. (#14816) - Added the
-[MGLOfflineStorage preloadData:forURL:modificationDate:expirationDate:eTag:mustRevalidate:completionHandler:]method for determining when the data is ready to retrieve from the cache. (#188) - Fixed a crash when
-[MGLOfflinePack invalidate]is called on different threads. (#15582) - Fixed issues where an offline pack would stop downloading before completion. (#16230, #16240)
- When an offline pack encounters an HTTP 404 error, the
MGLOfflinePackUserInfoKeyErroruser info key of theMGLOfflinePackErrorNotificationnow indicates the resource that could not be downloaded. (#16240) - Expired resources are now fetched at a lower priority than new resources. (#15950)
Other changes
- Fixed a memory leak when zooming with any options enabled in the
MGLMapView.debugMaskproperty. (#15395) MGLLoggingLevelhas been updated to better match core log levels. You can now useMGLLoggingConfiguration.loggingLevelto filter logs from core. (#15120)
Install in Dash
Mapbox Reference