Skip to content

Commit

Permalink
Merge pull request #4 from nitrag/master
Browse files Browse the repository at this point in the history
Perfect, thanks @nitrag πŸ™
  • Loading branch information
Roman Blum authored Nov 4, 2016
2 parents 0243f36 + e88f93f commit 4e1f80a
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ use_frameworks!
project 'Mapbox-iOS-Examples.xcodeproj'

target 'Mapbox-iOS-Examples' do
pod 'Mapbox-iOS-SDK', podspec: 'https://raw.githubusercontent.com/mapbox/mapbox-gl-native/ios-v3.4.0-alpha.5/platform/ios/Mapbox-iOS-SDK.podspec'
pod 'Mapbox-iOS-SDK', podspec: 'https://raw.githubusercontent.com/mapbox/mapbox-gl-native/ios-v3.4.0-beta.2/platform/ios/Mapbox-iOS-SDK.podspec'
pod 'SwiftyJSON'
end
31 changes: 18 additions & 13 deletions src/Examples/ClusteringViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ class ClusteringViewController: UIViewController {
func loadData() {
let geoJSONURL = Bundle.main.url(forResource: "mcdonalds", withExtension: "geojson")!

let options = [MGLGeoJSONClusterOption: true,
MGLGeoJSONClusterRadiusOption: 50,
MGLGeoJSONClusterMaximumZoomLevelOption: 12] as [String : Any]
var options = [String : Any]()
options[MGLGeoJSONClusterOption] = true
options[MGLGeoJSONClusterRadiusOption] = 42
options[MGLGeoJSONClusterMaximumZoomLevelOption] = 20
options[MGLGeoJSONMaximumZoomLevelOption] = 20
options[MGLGeoJSONToleranceOption] = 0.42

let geoJSONSource = MGLGeoJSONSource(sourceIdentifier: "mcdonalds", url: geoJSONURL, options: options)
let geoJSONSource = MGLGeoJSONSource(identifier: "mcdonalds", url: geoJSONURL, options: options)
mapView.style().add(geoJSONSource)

for index in 0..<clusterLayers.count {
Expand All @@ -34,22 +37,24 @@ class ClusteringViewController: UIViewController {
gtePredicate :
NSCompoundPredicate(andPredicateWithSubpredicates: [gtePredicate, NSPredicate(format: "%K < %@", argumentArray: ["point_count", clusterLayers[index - 1][0] as! NSNumber])])

let circleBorder = MGLCircleStyleLayer(layerIdentifier: "cluster-\(index)-border", source: geoJSONSource)
circleBorder.circleColor = UIColor.white
circleBorder.circleRadius = (clusterLayers[index][2] as! Double * 1.2) as MGLStyleAttributeValue
let circleBorder = MGLCircleStyleLayer(identifier: "cluster-\(index)-border", source: geoJSONSource)
circleBorder.circleColor = MGLStyleConstantValue(rawValue: UIColor.white)
let radius = clusterLayers[index][2] as! Double * 1.2
circleBorder.circleRadius = MGLStyleConstantValue(rawValue: radius as NSNumber)
circleBorder.predicate = allPredicate
mapView.style().add(circleBorder)

let circle = MGLCircleStyleLayer(layerIdentifier: "cluster-\(index)", source: geoJSONSource)
circle.circleColor = clusterLayers[index][1] as! UIColor
circle.circleRadius = clusterLayers[index][2] as! MGLStyleAttributeValue
let circle = MGLCircleStyleLayer(identifier: "cluster-\(index)", source: geoJSONSource)
circle.circleColor = MGLStyleConstantValue(rawValue: clusterLayers[index][1] as! UIColor)
let radius2 = clusterLayers[index][2] as! Double
circle.circleRadius = MGLStyleConstantValue(rawValue: radius2 as NSNumber)
circle.predicate = allPredicate
mapView.style().add(circle)
}

let clusterPointCountLayer = MGLSymbolStyleLayer(layerIdentifier: "cpc-layer", source: geoJSONSource)
clusterPointCountLayer.textField = "{point_count}" as MGLStyleAttributeValue!
clusterPointCountLayer.textColor = UIColor.white
let clusterPointCountLayer = MGLSymbolStyleLayer(identifier: "cpc-layer", source: geoJSONSource)
clusterPointCountLayer.textField = MGLStyleConstantValue(rawValue: "{point_count}")
clusterPointCountLayer.textColor = MGLStyleConstantValue(rawValue: UIColor.white)
mapView.style().add(clusterPointCountLayer)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Examples/FilteringDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class FilteringLayer {
let color: UIColor
let predicate: NSPredicate

public var styleLayer: MGLBaseStyleLayer!
public var styleLayer: MGLStyleLayer!

init(title: String, iconName: String, color: UIColor, predicate: NSPredicate) {
self.title = title
Expand Down
6 changes: 3 additions & 3 deletions src/Examples/FilteringViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class FilteringViewController: UIViewController, UITableViewDelegate, UITableVie
private func loadData() {
let geoJSONURL = Bundle.main.url(forResource: "siliconvalley", withExtension: "geojson")!

geoJSONSource = MGLGeoJSONSource(sourceIdentifier: "sv", url: geoJSONURL)
geoJSONSource = MGLGeoJSONSource(identifier: "sv", url: geoJSONURL)
mapView.style().add(geoJSONSource)

for layer in dataSource.layers {
let styleLayer = MGLSymbolStyleLayer(layerIdentifier: layer.title, source: geoJSONSource)
let styleLayer = MGLSymbolStyleLayer(identifier: layer.title, source: geoJSONSource)
styleLayer.predicate = layer.predicate
styleLayer.iconImage = layer.iconName as MGLStyleAttributeValue!
//styleLayer.iconImage = MGLStyleConstantValue(rawValue: layer.name)
mapView.style().add(styleLayer)

layer.styleLayer = styleLayer
Expand Down
14 changes: 7 additions & 7 deletions src/Examples/PathSelectionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ class PathSelectionViewController: UIViewController {
func mapViewDidFinishLoadingMap(_ mapView: MGLMapView) {
let geoJSONURL = Bundle.main.url(forResource: "portland", withExtension: "geojson")!

let geoJSONSource = MGLGeoJSONSource(sourceIdentifier: "portland", url: geoJSONURL)
let geoJSONSource = MGLGeoJSONSource(identifier: "portland", url: geoJSONURL)
mapView.style().add(geoJSONSource)

let styleLayer = MGLLineStyleLayer(layerIdentifier: "portland-layer", source: geoJSONSource)
styleLayer.lineWidth = 5 as MGLStyleAttributeValue!
styleLayer.lineColor = UIColor.gray
let styleLayer = MGLLineStyleLayer(identifier: "portland-layer", source: geoJSONSource)
styleLayer.lineWidth = MGLStyleConstantValue(rawValue: 5)
styleLayer.lineColor = MGLStyleConstantValue(rawValue: UIColor.gray)
mapView.style().add(styleLayer)

highlightedLine = MGLLineStyleLayer(layerIdentifier: "trackhl-layer", source: geoJSONSource)
highlightedLine.lineWidth = 5 as MGLStyleAttributeValue!
highlightedLine.lineColor = UIColor(colorLiteralRed: 0/255.0, green: 122/255.0, blue: 255/255.0, alpha: 1)
highlightedLine = MGLLineStyleLayer(identifier: "trackhl-layer", source: geoJSONSource)
highlightedLine.lineWidth = MGLStyleConstantValue(rawValue: 5)
highlightedLine.lineColor = MGLStyleConstantValue(rawValue: UIColor(colorLiteralRed: 0/255.0, green: 122/255.0, blue: 255/255.0, alpha: 1) )
highlightedLine.predicate = NSPredicate(value: false)
mapView.style().add(highlightedLine)
}
Expand Down
10 changes: 5 additions & 5 deletions src/Examples/PolygonsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ class PolygonsViewController: UIViewController, MGLMapViewDelegate {

private func loadData() {
let geoJSONURL = Bundle.main.url(forResource: "amsterdam", withExtension: "geojson")!
let geoJSONSource = MGLGeoJSONSource(sourceIdentifier: "ams", url: geoJSONURL)
let geoJSONSource = MGLGeoJSONSource(identifier: "ams", url: geoJSONURL)
mapView.style().add(geoJSONSource)
let styleLayer = MGLFillStyleLayer(layerIdentifier: "ams-layer", source: geoJSONSource)
styleLayer.fillColor = UIColor.purple
styleLayer.fillOpacity = 0.5 as MGLStyleAttributeValue!
styleLayer.fillOutlineColor = UIColor.purple
let styleLayer = MGLFillStyleLayer(identifier: "ams-layer", source: geoJSONSource)
styleLayer.fillColor = MGLStyleConstantValue(rawValue: UIColor.purple)
styleLayer.fillOpacity = MGLStyleConstantValue(rawValue: 0.5)
styleLayer.fillOutlineColor = MGLStyleConstantValue(rawValue: UIColor.purple)
mapView.style().add(styleLayer)
}

Expand Down
6 changes: 3 additions & 3 deletions src/Examples/SemanticZoomingViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SemanticZoomingViewController: UIViewController, MGLMapViewDelegate {

private func loadData() {
let geoJSONURL = Bundle.main.url(forResource: "siliconvalley", withExtension: "geojson")!
geoJSONSource = MGLGeoJSONSource(sourceIdentifier: "sv", url: geoJSONURL)
geoJSONSource = MGLGeoJSONSource(identifier: "sv", url: geoJSONURL)
mapView.style().add(geoJSONSource)

for layer in dataSource.layers {
Expand All @@ -32,9 +32,9 @@ class SemanticZoomingViewController: UIViewController, MGLMapViewDelegate {
}

private func add(layer: SemanticZoomingLayer) {
let styleLayer = MGLCircleStyleLayer(layerIdentifier: layer.title, source: geoJSONSource)
let styleLayer = MGLCircleStyleLayer(identifier: layer.title, source: geoJSONSource)
styleLayer.predicate = layer.predicate
styleLayer.circleColor = layer.color
styleLayer.circleColor = MGLStyleConstantValue(rawValue: layer.color)
styleLayer.minimumZoomLevel = layer.minimumZoomLevel
mapView.style().add(styleLayer)
}
Expand Down

0 comments on commit 4e1f80a

Please sign in to comment.