Updating examples

This commit is contained in:
Petr Pokorny
2021-01-31 01:48:55 +01:00
parent 2e89c0132f
commit f208eb998b
9 changed files with 60 additions and 0 deletions

View File

@@ -91,6 +91,15 @@ typedef NS_ENUM(NSUInteger, MGLCircleTranslationAnchor) {
### Example
```swift
let layer = MGLCircleStyleLayer(identifier: "circles", source: population)
layer.sourceLayerIdentifier = "population"
layer.circleColor = NSExpression(forConstantValue: UIColor.green)
layer.circleRadius = NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'exponential', 1.75, %@)",
[12: 2,
22: 180])
layer.circleOpacity = NSExpression(forConstantValue: 0.7)
layer.predicate = NSPredicate(format: "%K == %@", "marital-status", "married")
mapView.style?.addLayer(layer)
```
*/
MGL_EXPORT

View File

@@ -47,6 +47,12 @@ typedef NS_ENUM(NSUInteger, MGLFillExtrusionTranslationAnchor) {
### Example
```swift
let layer = MGLFillExtrusionStyleLayer(identifier: "buildings", source: buildings)
layer.sourceLayerIdentifier = "building"
layer.fillExtrusionHeight = NSExpression(forKeyPath: "height")
layer.fillExtrusionBase = NSExpression(forKeyPath: "min_height")
layer.predicate = NSPredicate(format: "extrude == 'true'")
mapView.style?.addLayer(layer)
```
*/
MGL_EXPORT

View File

@@ -51,6 +51,11 @@ typedef NS_ENUM(NSUInteger, MGLFillTranslationAnchor) {
### Example
```swift
let layer = MGLFillStyleLayer(identifier: "parks", source: parks)
layer.sourceLayerIdentifier = "parks"
layer.fillColor = NSExpression(forConstantValue: UIColor.green)
layer.predicate = NSPredicate(format: "type == %@", "national-park")
mapView.style?.addLayer(layer)
```
*/
MGL_EXPORT

View File

@@ -40,6 +40,14 @@ NS_ASSUME_NONNULL_BEGIN
### Example
```swift
let layer = MGLHeatmapStyleLayer(identifier: "earthquake-heat", source: earthquakes)
layer.heatmapWeight = NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:(magnitude, 'linear', nil, %@)",
[0: 0,
6: 1])
layer.heatmapIntensity = NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)",
[0: 1,
9: 3])
mapView.style?.addLayer(layer)
```
*/
MGL_EXPORT

View File

@@ -48,6 +48,11 @@ typedef NS_ENUM(NSUInteger, MGLHillshadeIlluminationAnchor) {
### Example
```swift
let layer = MGLHillshadeStyleLayer(identifier: "hills", source: source)
layer.hillshadeExaggeration = NSExpression(forConstantValue: 0.6)
if let canalShadowLayer = mapView.style?.layer(withIdentifier: "waterway-river-canal-shadow") {
mapView.style?.insertLayer(layer, below: canalShadowLayer)
}
```
*/
MGL_EXPORT

View File

@@ -62,6 +62,11 @@ NS_INLINE MGLSphericalPosition MGLSphericalPositionMake(CGFloat radial, CLLocati
### Example
```swift
let light = MGLLight()
let position = MGLSphericalPosition(radial: 5, azimuthal: 180, polar: 80)
light.position = NSExpression(forConstantValue: NSValue(mglSphericalPosition: position))
light.anchor = NSExpression(forConstantValue: "map")
mapView.style?.light = light
```
#### Related examples

View File

@@ -101,6 +101,15 @@ typedef NS_ENUM(NSUInteger, MGLLineTranslationAnchor) {
### Example
```swift
let layer = MGLLineStyleLayer(identifier: "trails-path", source: trails)
layer.sourceLayerIdentifier = "trails"
layer.lineWidth = NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'exponential', 1.5, %@)",
[14: 2,
18: 20])
layer.lineColor = NSExpression(forConstantValue: UIColor.brown)
layer.lineCap = NSExpression(forConstantValue: "round")
layer.predicate = NSPredicate(format: "%K == %@", "trail-type", "mountain-biking")
mapView.style?.addLayer(layer)
```
*/
MGL_EXPORT

View File

@@ -61,6 +61,9 @@ typedef NS_ENUM(NSUInteger, MGLRasterResamplingMode) {
### Example
```swift
let layer = MGLRasterStyleLayer(identifier: "clouds", source: source)
layer.rasterOpacity = NSExpression(forConstantValue: 0.5)
mapView.style?.addLayer(layer)
```
*/
MGL_EXPORT

View File

@@ -402,6 +402,16 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslationAnchor) {
### Example
```swift
let layer = MGLSymbolStyleLayer(identifier: "coffeeshops", source: pois)
layer.sourceLayerIdentifier = "pois"
layer.iconImageName = NSExpression(forConstantValue: "coffee")
layer.iconScale = NSExpression(forConstantValue: 0.5)
layer.text = NSExpression(forKeyPath: "name")
layer.textTranslation = NSExpression(forConstantValue: NSValue(cgVector: CGVector(dx: 10, dy: 0)))
layer.textJustification = NSExpression(forConstantValue: "left")
layer.textAnchor = NSExpression(forConstantValue: "left")
layer.predicate = NSPredicate(format: "%K == %@", "venue-type", "coffee")
mapView.style?.addLayer(layer)
```
*/
MGL_EXPORT