-
Notifications
You must be signed in to change notification settings - Fork 35
[ios] Add example for variable label placement. #286
Conversation
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.
👀 My comments on the Objective-C file also apply to the corresponding Swift file as well.
Examples/Examples.h
Outdated
@@ -61,6 +61,7 @@ extern NSString *const MBXExampleThirdPartyVectorStyle; | |||
extern NSString *const MBXExampleUserLocationAnnotation; | |||
extern NSString *const MBXExampleUserTrackingModes; | |||
extern NSString *const MBXExampleWebAPIData; | |||
extern NSString *const MBXExampleLabelPlacement; |
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.
Please put this under line 40 to keep this in alphabetical order.
// Created by Fabian Guerra Soto on 4/2/19. | ||
// Copyright © 2019 Mapbox. All rights reserved. | ||
// | ||
|
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.
It is customary for this project to remove the above information.
poiLabelLayers.textOffset = nil; | ||
poiLabelLayers.symbolPlacement = nil; | ||
poiLabelLayers.textOffset = nil; | ||
// poiLabelLayers.textVariableAnchor = [NSExpression expressionForConstantValue:@[@(MGLTextAnchorTop), @(MGLTextAnchorRight)]]; |
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.
If you intend to keep these comments in, can you explain what uncommenting them will do?
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.
This is the code that does the label placement. But I don't have a beta release that contains such code, that's why I commented this code while waiting for beta.2. Once that is released will uncomment.
} | ||
|
||
- (void)mapView:(MGLMapView *)mapView didFinishLoadingStyle:(MGLStyle *)style { | ||
MGLSymbolStyleLayer *poiLabelLayers = (MGLSymbolStyleLayer *)[self.mapView.style layerWithIdentifier:@"poi-label"]; |
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.
Its important to mention here that the poi-label
layer is specific to Mapbox styles that include the mapbox-streets-v8
source, which you may want to link to here: https://docs.mapbox.com/vector-tiles/reference/mapbox-streets-v8/#poi_label
poiLabelLayers.textAnchor = nil; | ||
poiLabelLayers.textOffset = nil; | ||
poiLabelLayers.symbolPlacement = nil; | ||
poiLabelLayers.textOffset = nil; |
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.
Can you please explain what the default styling for the poi-label
looks like? For example, by default it shows a symbol (or "icon") with the text below it, and the modification you are making above will undo that.
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.
This refers to label collision, when you turn on the label placement anchors the collision detection re-positions the labels.
Here is how it looks:
mapbox/mapbox-gl-js#7596 (comment)
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.
Thanks for the detailed feedback @captainbarbosa! @fabian-guerra will address these comments next week when they are added as official parts of our example documentation. For now I'll approve so we can test with the beta release.
acd788f
to
b9eb168
Compare
Added test case for text label placement feature.
Added test case for text label placement feature.
Example that shows how to use variable label placement: mapbox/mapbox-gl-native#14184