-
Notifications
You must be signed in to change notification settings - Fork 8
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
[WIP] Traffic plugin #9
Changes from 12 commits
c668d1e
7fd48a7
2918d13
a152b6e
40d9c89
a0c9bb5
7705747
f91405c
4b40bfd
5df3231
9b67e32
7b69be8
860a970
cf8fb8f
4f3aa6a
543c321
d042115
94a48c0
40e110f
1bfac30
0afafb1
e1630d2
eb6e790
4b923d9
1b8af7b
082f207
8079053
ee348aa
bbad61a
8ab9926
2d3c1cc
e92db09
720bebf
b7851ad
569c9e7
5617295
b75e474
c55b5db
c3619bf
1fd4ed6
411fb28
79d2755
c51c5d0
e5f966d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,6 @@ xcuserdata | |
*.moved-aside | ||
*.xcuserstate | ||
*.xcscmblueprint | ||
mapbox_access_token | ||
|
||
|
||
Carthage/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Copyright © 2014–2017, Mapbox | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We didn’t start working on these plugins until this year. |
||
|
||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# | ||
# Be sure to run `pod spec lint MapboxPlugins.podspec' to ensure this is a | ||
# valid spec and to remove all comments including this before submitting the spec. | ||
# | ||
# To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html | ||
# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ | ||
# | ||
|
||
Pod::Spec.new do |s| | ||
|
||
# ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # | ||
# | ||
# These will help people to find your library, and whilst it | ||
# can feel like a chore to fill in it's definitely to your advantage. The | ||
# summary should be tweet-length, and the description more in depth. | ||
# | ||
|
||
s.name = "MapboxMapsPlugins" | ||
s.version = "0.0.1" | ||
s.summary = "Experimental plugins to supercharge your maps." | ||
|
||
# This description is used to generate tags and improve search results. | ||
# * Think: What does it do? Why did you write it? What is the focus? | ||
# * Try to keep it short, snappy and to the point. | ||
# * Write the description between the DESC delimiters below. | ||
# * Finally, don't worry about the indent, CocoaPods strips it! | ||
s.description = "Add traffic to your Mapbox basemaps." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Traffic won’t be the only plugin. |
||
|
||
s.homepage = "https://github.com/mapbox/mapbox-plugins-ios/" | ||
# s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" | ||
|
||
|
||
# ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # | ||
|
||
s.license = { :type => "ISC", :file => "LICENSE.md" } | ||
|
||
# ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # | ||
|
||
s.author = { "Mapbox" => "[email protected]" } | ||
s.social_media_url = "https://twitter.com/mapbox" | ||
|
||
# ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # | ||
# | ||
# If this Pod runs only on iOS or OS X, then specify the platform and | ||
# the deployment target. You can optionally include the target after the platform. | ||
# | ||
|
||
# s.platform = :ios | ||
# s.platform = :ios, "5.0" | ||
|
||
# When using multiple platforms | ||
# s.ios.deployment_target = "5.0" | ||
# s.osx.deployment_target = "10.7" | ||
# s.watchos.deployment_target = "2.0" | ||
# s.tvos.deployment_target = "9.0" | ||
|
||
|
||
# ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # | ||
# | ||
# Specify the location from where the source should be retrieved. | ||
# Supports git, hg, bzr, svn and HTTP. | ||
# | ||
|
||
s.source = { :git => "http://github.com/mapbox/mapbox-plugins-ios.git", :branch => "traffic-plugin" } | ||
|
||
s.subspec 'PluginKit' do |core| | ||
core.source_files = 'PluginKit/*.h' | ||
core.dependency 'Mapbox-iOS-SDK', "~> 3.6" | ||
end | ||
|
||
s.subspec 'Traffic' do |traffic| | ||
traffic.source_files = 'TrafficPlugin/*.{h,m}' | ||
traffic.dependency 'MapboxMapsPlugins/PluginKit' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to provide a description per subspec? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't seem to be. I didn't see anything in the CocoaPods docs. 😞 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like the usual practice is to list and describe all the plugins in the main spec’s description, which can have an arbitrary amount of Markdown. |
||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
objects = { | ||
|
||
/* Begin PBXBuildFile section */ | ||
3E0EC62B1F5779C5006BC03F /* MBXTrafficPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E0EC6291F5779C5006BC03F /* MBXTrafficPlugin.m */; }; | ||
DA8805671ED342F0000CB4A8 /* LocalizationPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = DA8805651ED342F0000CB4A8 /* LocalizationPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; }; | ||
DA88056A1ED342F0000CB4A8 /* LocalizationPlugin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA8805631ED342F0000CB4A8 /* LocalizationPlugin.framework */; }; | ||
DA88056B1ED342F0000CB4A8 /* LocalizationPlugin.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DA8805631ED342F0000CB4A8 /* LocalizationPlugin.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; | ||
|
@@ -70,6 +71,10 @@ | |
/* End PBXCopyFilesBuildPhase section */ | ||
|
||
/* Begin PBXFileReference section */ | ||
3E0EC6291F5779C5006BC03F /* MBXTrafficPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MBXTrafficPlugin.m; path = TrafficPlugin/MBXTrafficPlugin.m; sourceTree = SOURCE_ROOT; }; | ||
3E0EC62A1F5779C5006BC03F /* MBXTrafficPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MBXTrafficPlugin.h; path = TrafficPlugin/MBXTrafficPlugin.h; sourceTree = SOURCE_ROOT; }; | ||
3E0EC62D1F577BBE006BC03F /* MBXPlugin-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MBXPlugin-Bridging-Header.h"; sourceTree = "<group>"; }; | ||
3E45FEBC1F588709001EB296 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; | ||
DA8805631ED342F0000CB4A8 /* LocalizationPlugin.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = LocalizationPlugin.framework; sourceTree = BUILT_PRODUCTS_DIR; }; | ||
DA8805651ED342F0000CB4A8 /* LocalizationPlugin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LocalizationPlugin.h; sourceTree = "<group>"; }; | ||
DA8805661ED342F0000CB4A8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; | ||
|
@@ -94,7 +99,6 @@ | |
DAF50B331ECA15B50044B316 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; }; | ||
DAF50B351ECA15B50044B316 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; | ||
DAF50B381ECA15B50044B316 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; | ||
DAF50B3A1ECA15B50044B316 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; | ||
/* End PBXFileReference section */ | ||
|
||
/* Begin PBXFrameworksBuildPhase section */ | ||
|
@@ -125,6 +129,16 @@ | |
/* End PBXFrameworksBuildPhase section */ | ||
|
||
/* Begin PBXGroup section */ | ||
3EEB5A7C1F4F7ED9008E73B6 /* TrafficPlugin */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
3E0EC62A1F5779C5006BC03F /* MBXTrafficPlugin.h */, | ||
3E0EC6291F5779C5006BC03F /* MBXTrafficPlugin.m */, | ||
); | ||
name = TrafficPlugin; | ||
path = Funhouse; | ||
sourceTree = "<group>"; | ||
}; | ||
DA8805641ED342F0000CB4A8 /* LocalizationPlugin */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
|
@@ -142,6 +156,7 @@ | |
isa = PBXGroup; | ||
children = ( | ||
DA88057A1ED34744000CB4A8 /* MapboxPluginKit.h */, | ||
3E0EC62D1F577BBE006BC03F /* MBXPlugin-Bridging-Header.h */, | ||
DA8805811ED34787000CB4A8 /* MBXPlugin.h */, | ||
); | ||
path = PluginKit; | ||
|
@@ -160,6 +175,7 @@ | |
children = ( | ||
DAF50B251ECA15B50044B316 /* TestApp */, | ||
DA8805641ED342F0000CB4A8 /* LocalizationPlugin */, | ||
3EEB5A7C1F4F7ED9008E73B6 /* TrafficPlugin */, | ||
DA8805791ED34744000CB4A8 /* PluginKit */, | ||
DAF50B241ECA15B50044B316 /* Products */, | ||
DA88058C1ED3950D000CB4A8 /* Frameworks */, | ||
|
@@ -187,10 +203,10 @@ | |
DAF50B301ECA15B50044B316 /* MapViewController.m */, | ||
DA8805881ED34CD2000CB4A8 /* PluginTableViewController.h */, | ||
DA8805891ED34CD2000CB4A8 /* PluginTableViewController.m */, | ||
3E45FEBC1F588709001EB296 /* Info.plist */, | ||
DAF50B321ECA15B50044B316 /* Main.storyboard */, | ||
DAF50B351ECA15B50044B316 /* Assets.xcassets */, | ||
DAF50B371ECA15B50044B316 /* LaunchScreen.storyboard */, | ||
DAF50B3A1ECA15B50044B316 /* Info.plist */, | ||
DAF50B261ECA15B50044B316 /* Supporting Files */, | ||
); | ||
path = TestApp; | ||
|
@@ -275,6 +291,7 @@ | |
DAF50B211ECA15B50044B316 /* Resources */, | ||
DA88056F1ED342F0000CB4A8 /* Embed Frameworks */, | ||
DA8805901ED39532000CB4A8 /* Copy Frameworks */, | ||
3E0EC6281F55D2D8006BC03F /* ShellScript */, | ||
); | ||
buildRules = ( | ||
); | ||
|
@@ -353,6 +370,19 @@ | |
/* End PBXResourcesBuildPhase section */ | ||
|
||
/* Begin PBXShellScriptBuildPhase section */ | ||
3E0EC6281F55D2D8006BC03F /* ShellScript */ = { | ||
isa = PBXShellScriptBuildPhase; | ||
buildActionMask = 2147483647; | ||
files = ( | ||
); | ||
inputPaths = ( | ||
); | ||
outputPaths = ( | ||
); | ||
runOnlyForDeploymentPostprocessing = 0; | ||
shellPath = /bin/sh; | ||
shellScript = "$SRCROOT/insert-mapbox-token.sh"; | ||
}; | ||
DA8805901ED39532000CB4A8 /* Copy Frameworks */ = { | ||
isa = PBXShellScriptBuildPhase; | ||
buildActionMask = 2147483647; | ||
|
@@ -407,6 +437,7 @@ | |
buildActionMask = 2147483647; | ||
files = ( | ||
DAF50B2B1ECA15B50044B316 /* AppDelegate.m in Sources */, | ||
3E0EC62B1F5779C5006BC03F /* MBXTrafficPlugin.m in Sources */, | ||
DA88058A1ED34CD2000CB4A8 /* PluginTableViewController.m in Sources */, | ||
DAF50B2E1ECA15B50044B316 /* MasterViewController.m in Sources */, | ||
DAF50B281ECA15B50044B316 /* main.m in Sources */, | ||
|
@@ -568,6 +599,7 @@ | |
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | ||
GCC_WARN_UNUSED_FUNCTION = YES; | ||
GCC_WARN_UNUSED_VARIABLE = YES; | ||
INFOPLIST_FILE = "$/mapbox-plugins-ios/TestApp/Info.plist"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a strange path to see here. Normally I’d expect to see |
||
IPHONEOS_DEPLOYMENT_TARGET = 10.0; | ||
MTL_ENABLE_DEBUG_INFO = YES; | ||
ONLY_ACTIVE_ARCH = YES; | ||
|
@@ -611,6 +643,7 @@ | |
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | ||
GCC_WARN_UNUSED_FUNCTION = YES; | ||
GCC_WARN_UNUSED_VARIABLE = YES; | ||
INFOPLIST_FILE = "$/mapbox-plugins-ios/TestApp/Info.plist"; | ||
IPHONEOS_DEPLOYMENT_TARGET = 10.0; | ||
MTL_ENABLE_DEBUG_INFO = NO; | ||
SDKROOT = iphoneos; | ||
|
@@ -628,7 +661,7 @@ | |
"$(inherited)", | ||
"$(PROJECT_DIR)/Carthage/Build/iOS", | ||
); | ||
INFOPLIST_FILE = Funhouse/Info.plist; | ||
INFOPLIST_FILE = "$(SRCROOT)/TestApp/Info.plist"; | ||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; | ||
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.PluginFunhouse; | ||
PRODUCT_NAME = "$(TARGET_NAME)"; | ||
|
@@ -644,7 +677,7 @@ | |
"$(inherited)", | ||
"$(PROJECT_DIR)/Carthage/Build/iOS", | ||
); | ||
INFOPLIST_FILE = Funhouse/Info.plist; | ||
INFOPLIST_FILE = "$(SRCROOT)/TestApp/Info.plist"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aw, I liked the Funhouse name. It was a nod to the Core Image Fun House application. 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do like the Funhouse name, but Funhouses are kind of scary. |
||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; | ||
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.PluginFunhouse; | ||
PRODUCT_NAME = "$(TARGET_NAME)"; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// MBXPlugin-Bridging-Header.h | ||
// MapboxPlugins | ||
// | ||
// Created by Jordan Kiley on 8/30/17. | ||
// Copyright © 2017 Mapbox. All rights reserved. | ||
// | ||
|
||
#ifndef MBXPlugin_Bridging_Header_h | ||
#define MBXPlugin_Bridging_Header_h | ||
|
||
|
||
#endif /* MBXPlugin_Bridging_Header_h */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,70 @@ | ||
# mapbox-plugins-ios | ||
Experimental plugins to supercharge your maps ⚡️ | ||
|
||
## Installing Plugins | ||
|
||
There are main three ways to install Mapbox Maps Plugins: | ||
|
||
1. CocoaPods | ||
To install all Mapbox Maps Plugins, add the following to your Podfile: | ||
`pod MapboxMapsPlugins` | ||
To install the Mapbox Traffic Plugin, add | ||
`pod MapboxMapsPlugins/Traffic` | ||
Note that the CocoaPod does include Mapbox iOS SDK v3.6.x as a dependency, and should update to the latest patch release of v3.6 when you run `pod update`. | ||
2. Carthage 🤷 | ||
3. If you prefer not to use either Carthage or CocoaPods, copy the files for the plugin that you would like to use into your project. You will need to use a bridging header if your project is written in Swift. | ||
|
||
## Using Test App | ||
|
||
Test out Mapbox Maps Plugins in the TestApp. Add your [Mapbox Access token](https://www.mapbox.com/help/how-access-tokens-work/) to the `mapbox_access_token` file to get started. | ||
|
||
## Getting Started with the Traffic Plugin | ||
|
||
Once you have added the plugins library to your project, import it to your project. The traffic layers will start to become visible at zoom level 10. | ||
|
||
Because these methods use the Runtime Styling API, the earliest that they can be called is in `[-mapView:didFinishLoadingStyle:](https://www.mapbox.com/ios-sdk/api/3.6.2/Protocols/MGLMapViewDelegate.html#/c:objc(pl)MGLMapViewDelegate(im)mapView:didFinishLoadingStyle:)`. | ||
|
||
- (void)addToMapView:(MGLMapView *)mapView; | ||
|
||
Add traffic to a MGLMapView. This method inserts the traffic layer below places of interest with a scale rank of 3 (POIs that either have a small area or are generally acknowledged to cover large areas, i.e. hospitals and universities). See the [Mapbox Vector Tile Source layer reference](https://www.mapbox.com/vector-tiles/mapbox-streets-v7/#layer-reference) for more information about vector tile layers. | ||
|
||
- (void)addToMapView:(MGLMapView *)mapView below:(MGLStyleLayer *)symbolLayer; | ||
|
||
Insert the traffic layers below a specific layer that has already been added to your map’s style. | ||
|
||
- (void)removeFromMapView:(MGLMapView *)mapView; | ||
|
||
Removes all traffic layers from the map. | ||
|
||
|
||
## Examples | ||
|
||
### Swift | ||
```swift | ||
import Mapbox | ||
import MapboxMapsPlugins | ||
|
||
class ViewController: UIViewController, MGLMapViewDelegate { | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
// This example is pinned to a style version because it accesses underlying style data. | ||
let mapView = MGLMapView(frame: view.bounds, styleURL: MGLStyle.lightStyleURL(withVersion: 9)) | ||
mapView.setCenter(CLLocationCoordinate2D(latitude: 39.9612, longitude: -82.9988), zoomLevel: 11, animated: false) | ||
mapView.autoresizingMask = [.flexibleHeight, .flexibleWidth] | ||
view.addSubview(mapView) | ||
mapView.delegate = self | ||
} | ||
|
||
func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) { | ||
let traffic = MBXTrafficPlugin() | ||
traffic.add(to: mapView) | ||
|
||
// Removes the traffic layers after 10 seconds. | ||
DispatchQueue.main.asyncAfter(deadline: .now() + 10, execute: { | ||
traffic.remove(from: mapView) | ||
}) | ||
} | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm, I think
mapbox_access_token
still needs to be ignored, it’s just that creating the file is a necessary step towards getting the demo app working.