Updating examples
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user