mapbox / mapbox/mapbox-maps-flutter
Method getLayer("puck") throws "Layer puck is not in style"
Nobody has claimed this yet.
- Dominant language
- Dart
- Stars
- 380
- Forks
- 204
- PR merge metrics
- No merged PRs in 30d
Description
On iOS (haven't tested Android) when trying to get the position of the user with the provided code in the example
// wait until the style is loaded
await state?.style.isStyleLoaded();
// get the user position from the layer that contains the puck (the blue dot)
Layer? layer;
if (Platform.isAndroid) {
layer = await state?.style.getLayer("mapbox-location-indicator-layer");
} else {
layer = await state?.style.getLayer("puck");
}
final userLocation = (layer as LocationIndicatorLayer).location;
return Position(userLocation![1]!, userLocation[0]!);
as soon as the map is created then this error is thrown:
PlatformException (PlatformException(StyleError(rawValue: "Layer puck is not in style"), null, null, null))
Before updating to 1.1.0 from a pre 1.0.0 version this issue wasn't there; trying to get the position slightly after the map creation doesn't yield the Exception.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided example code and reproduce the failure on iOS immediately after map creation, then compare it with a delayed lookup. Trace the style readiness and availability of the "puck" layer around getLayer("puck"). Done means the example can obtain the user position after the map is created without the Layer puck is not in style exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter, ios
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100