Skip to content
This repository was archived by the owner on Jun 14, 2024. It is now read-only.

Extrusions example #86

Merged
merged 6 commits into from
May 22, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Examples/ObjectiveC/ExtrusionsExample.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ - (void)mapView:(MGLMapView *)mapView didFinishLoadingStyle:(MGLStyle *)style {
layer.sourceLayerIdentifier = @"building";

// Filter out buildings that should not extrude.
layer.predicate = [NSPredicate predicateWithFormat:@"height >= 0"];
layer.predicate = [NSPredicate predicateWithFormat:@"extrude == %@ AND height >= 0", @"true"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Per mapbox/mapbox-gl-native#9056 (comment), this can be written extrude == 'true'.


// Set the fill extrusion height to the value for the building height attribute.
layer.fillExtrusionHeight = [MGLStyleValue valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"height" options:nil];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should set fillExtrusionBase too, so that roofs and skywalks don’t fill the space below. The coliseum will probably look a little better that way, too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to set fillExtrusionBase too: #86 (comment).

layer.fillExtrusionBase =[MGLStyleValue valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"min_height" options:nil];
layer.fillExtrusionOpacity = [MGLStyleValue valueWithRawValue:@0.75];
layer.fillExtrusionColor = [MGLStyleValue valueWithRawValue:[UIColor whiteColor]];

Expand Down
3 changes: 2 additions & 1 deletion Examples/Swift/ExtrusionsExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ class ExtrusionsExample: UIViewController, MGLMapViewDelegate {
layer.sourceLayerIdentifier = "building"

// Filter out buildings that should not extrude.
layer.predicate = NSPredicate(format: "height >= 0")
layer.predicate = NSPredicate(format: "extrude == %@ AND height >= 0", "true")

// Set the fill extrusion height to the value for the building height attribute.
layer.fillExtrusionHeight = MGLStyleValue(interpolationMode: .identity, sourceStops: nil, attributeName: "height", options: nil)
layer.fillExtrusionBase = MGLStyleValue(interpolationMode: .identity, sourceStops: nil, attributeName: "min_height", options: nil)
layer.fillExtrusionOpacity = MGLStyleValue(rawValue: 0.75)
layer.fillExtrusionColor = MGLStyleValue(rawValue: .white)

Expand Down