-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LineLayer not visible if conditionally rendered #594
Comments
Thanks for the report, does this also happen with the latest beta? |
@KiwiKilian yes, I see the same behaviour with |
Can confirm on iOS and new architecture. Here is a minimal reproduction without other deps, press the back button to make the line visible: import {
LineLayer,
MapView,
ShapeSource,
} from "@maplibre/maplibre-react-native";
import type { Geometry } from "geojson";
import { useEffect, useState } from "react";
export function BugReport() {
const [shape, setShape] = useState<Geometry>();
useEffect(() => {
// Simulate network request
setTimeout(() => {
setShape({
type: "LineString",
coordinates: [
[0, 0],
[50, 50],
],
});
}, 500);
}, []);
return (
<>
<MapView style={{ flex: 1 }}>
{shape && (
<ShapeSource key="shape-source" id="line-source" shape={shape}>
<LineLayer
key="line-layer"
id="polyline"
style={{ lineColor: "#37BDEF", lineWidth: 4 }}
/>
</ShapeSource>
)}
</MapView>
</>
);
} Here is a workaround. It seems like there is a problem, when the source and layer get added at the same time: import {
LineLayer,
MapView,
ShapeSource,
} from "@maplibre/maplibre-react-native";
import type { Geometry } from "geojson";
import { useEffect, useState } from "react";
export function BugReport() {
const [shape, setShape] = useState<Geometry>();
useEffect(() => {
// Simulate network request
setTimeout(() => {
setShape({
type: "LineString",
coordinates: [
[0, 0],
[50, 50],
],
});
}, 500);
}, []);
return (
<>
<MapView style={{ flex: 1 }}>
<ShapeSource
key="shape-source"
id="line-source"
shape={shape || { type: "GeometryCollection", geometries: [] }}
>
<LineLayer
key="line-layer"
id="polyline"
style={{ lineColor: "#37BDEF", lineWidth: 4 }}
/>
</ShapeSource>
</MapView>
</>
);
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps to Trigger Behavior
MapView
without a LineLayersetCamera
the LineLayer actually becomes visible.Link to Minimal Reproducible Example
https://github.com/bryanvanwijk/maplibre-test/blob/main/app/map.tsx
Expected Behavior
LineLayer is visible on the map when rendered
Actual Behavior
LineLayer is not visible
Screenshots (if applicable)
recording.mp4
Environment
@maplibre/maplibre-react-native
Version: 10.0.0-beta.18react-native
Version: 0.76.5expo
Version: 52.0.18Additional context
There is no issue without the new architecture enabled.
The text was updated successfully, but these errors were encountered: