I am using react-map-gl
and I am rendering markers within the map. I also have some hover animations going on, animations are only css so far, except when you click a marker (Not of importance for this question though).
So far it works as I want and it looks tidy.
But as you can see, in the middle of the map, I have a cluster of markers, they are close to each other. And when I hover one of them in the background it looks like this:
As you can see it does not place it self on top on the other markers, which is desired.
This is the CSS on hover:
.pointer {
transform-origin: bottom center;
width: 40px;
position: absolute;
display: flex;
justify-content: center;
align-items: center;
bottom:0;
transform: translateX(-50%);
&:hover {
animation-name: bounce;
animation-duration: .5s;
animation-fill-mode: forwards;
z-index: 1000;
+ .text {
animation-name: bounce-text;
animation-duration: .4s;
animation-fill-mode: forwards;
animation-delay: .2s;
}
}
}
As you can see I am trying to rise the z-index to 1000 on hover, but it has no effect. Probably since each <Marker/>
is absolute positioned and probably has it's own z-index stack.
Here is the Javascript for the Marker loop:
<ReactMapGl
ref={mapEl}
{...viewPort}
onViewportChange={(_viewport:any) => setViewport(_viewport)}
mapboxApiAccessToken={mapboxToken}
mapStyle="mapbox://styles/mapbox/satellite-v9"
style={{position:'relative', zIndex: '1'}}
>
{mapData.markerCategories.map((markerCategory, i) =>
<React.Fragment key={i}>
{markerCategory.markers.map((marker, i) => <Marker
latitude={marker.position[0]}
longitude={marker.position[1]}
key={i}
>
<Pointer viewPort={viewPort} marker={marker} markerCategory={markerCategory} setViewport={(viewPort:any) => setViewport(viewPort)}/>
</Marker>)}
</React.Fragment>
)}
</ReactMapGl>
The <Pointer/>
component is basically each graphic Icon with svg and CSS for it.
I can not find a solution of this. So my question is, how do I rise a marker to top on each hover by CSS (preferred) or JavaScript?