Repository navigation
[ios] Add example for variable label placement. - #286
Conversation
captainbarbosa
left a comment
There was a problem hiding this comment.
👀 My comments on the Objective-C file also apply to the corresponding Swift file as well.
| extern NSString *const MBXExampleUserLocationAnnotation; | ||
| extern NSString *const MBXExampleUserTrackingModes; | ||
| extern NSString *const MBXExampleWebAPIData; | ||
| extern NSString *const MBXExampleLabelPlacement; |
There was a problem hiding this comment.
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.
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.
If you intend to keep these comments in, can you explain what uncommenting them will do?
There was a problem hiding this comment.
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.
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.
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.
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)
chloekraw
left a comment
There was a problem hiding this comment.
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