-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Z-index issue on re-render with <UrlTile/> and <Polyline/> #1181
Comments
I had something similar, and changing the |
@dbrugne |
Searching in the source code, I noticed the Polyline has a zIndex property as well... I've set it explicitly to 5 and now it's appearing over the Tiles. Weird behaviour: |
@markmssd i'm adding/removing on different renders and it update displayed tiles accordingly. Are you sure that your render() is triggered while your props change? |
Changing zIndex property on UrlTile, Polyline and Circle hasn't any effect. It is a real bug. |
Are you on Android or iOS? I'm on iOS, and after I've added the zIndex on both Tiles and Polyline, the Polyline correctly renders on top of the Tiles. |
For the tiles not being updated... yes I've put couple of When you say that you |
My code (also work with inline JSX ternary in render() method: class MyMap extends Component {
// ...
firstOverlay = () => (this.props.mapOverlay === 'first'
? <UrlTile urlTemplate={myFirstUrlTemplate} />
: null);
secondOverlay = () => (this.props.mapOverlay === 'second'
? <UrlTile urlTemplate={myFirstUrlTemplate} />
: null);
// ...
render() {
return (
<MapView
style={styles.map}
initialRegion={{ ...initilalRegion }}
showsUserLocation
userLocationAnnotationTitle="Your position"
loadingEnabled
showsTraffic={false}
showsIndoors={false}
>
{this.firstOverlay()}
{this.secondOverlay()}
// ...
</MapView>
);
}
} |
Aah I see! So you're also doing a hackish solution. Ideally, when 'urlTemplate' changes, it should rerender the tiles... I'll use your solution as well for now and when I have time I'll PR a fix for it. Thanks! PS, any luck with your zIndex? It should work... it's working for me |
@markmssd lifesaver. Your Regarding the
should trigger a |
I'm still having an issue trying to control the order of appearance when using two UrlTiles layers. It doesn't matter which order the UrlTile layers are included, one layer (SECOND) always sits on top of the other. Example:
The SECOND UrlTile layer still loads on top of the first one. I can briefly see the FIRST layer while the SECOND is rendering @Stophface is your zIndex being set in an UrlTile component? Not sure why I can't get a zIndex working. Using the latest release. @markmssd if I understood your comment you indicated there was a PR to fix these issues. Was that also fixing the order of UrlTiles? |
If I'm understanding the code for UrlTile correctly the zIndex prop is only for Android? So how do you achieve the desired ordering of the layers in iOS? @Stophface |
@systemlevel I think you should try this option: Just add zIndex into styles |
Any progress. I still have the issue. my Overlay is hiding under UrlTile |
zIndex not really work. If you have some elements like:
The |
Another way to make dynamic
Not ideal, but makes rendering order intact. |
It worked for me. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I'm using latest release as well. Passing zIndex as prop in UrlTile or in style object is not working for me. I want to perform a smooth radar animation on google maps. The solution you suggest above to re-render that make a flicker. Any one please help me out? |
Hello, I am also using something similar like this. Basically I am creating this app where there is a slider and when I move the slider, app shows weather for the next hour. UrlTIle is updating thanks to key property, but it takes 2-3 seconds to load the image and show it on map. is there any way in react native where I can achieve this transition smoothly, like in apple weather app? If anyone know the answer to this please respond! |
@Khubaib69 are you playing an animation for the next hour? |
No I am not playing any animation. basically, there is a slider when slider is in the middle it shows current(time) weather layer, when slider is moved to the right it shows weather layer for next hour and when it is moved to left it shows the previous hour weather layer. I was able to achieve this by passing timestamp of next hour and previous hour in UrlTile urltemplate when changing slider. but as you said above it causes re-render that make a flicker. Is there any way I can this transition smooth? |
@Khubaib69 yes you can make it smooth. Load all three url tiles (previous hour, current and next hour) on the map. Then use opacity property to display and hide respective layers. |
I fixed this for android by setting , for ios i had to do a bit more. I had to force a re render for the component that gets overlapped as soon as the tiles are loaded in combination with a changing key like Date.now(). Only then it worked. |
Can you share some code how you did this? I'm still having the same issue. The UrlTile is loaded dynamically based on a boolean useState, which is causing the z-index issue. |
I've a got a use case where I have to display different cartography (from Gmap, Geoportail and custom tile server) as fullscreen and with some markers and polygons drawn on map.
I'm using MapView, UrlTitle, Circle and Polyline.
On first render I render the following tree and both MapView, UrlTitle, Marker, Circle and Polyline are displayed:
When user change cartography to display (via a menu) it triggers a re-render of my component with a new (or additionnal) UrlTile:
Everything works fine excepts that the new tiles are displayed over Polyline and Circle that are hidden. But not upon Marker that is still correctly displayed.
It seems like a z-index issue and uniquely when you vary UrlTile between different renders.
My workaround (until a definitive fix) will be to force a new MapView re-rendering.
Tested on iOS simulator iPhone 6/ iOS 10.2.
The text was updated successfully, but these errors were encountered: