-
Notifications
You must be signed in to change notification settings - Fork 426
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
Markers Size is changing on zoom in and zoom out #188
Comments
It's not well documented at the moment, but you can achieve this by using the Here's an example of this: |
Would love to see this documented and Also,
|
Hi there. In version const [scaleFactor, setScaleFactor] = useState(1);
//...
<ZoomableGroup onMove={({ k }) => setScaleFactor(k)}>
//...
<circle r={12 / scaleFactor} fill="#F53" /> See working example here See also docs here: https://www.react-simple-maps.io/docs/zoomable-group/ I believe the issue can be closed now |
Going forward, some hook like this one could be created and re-used across app export function useStaticMapMarkerSize(
markerRadius: number,
initialMapScaleFactor: number = 1
): [number, (scaleFactor: number) => void] {
const [scaleFactor, setScaleFactor] = useState<number>(initialMapScaleFactor)
const scaledRadius = markerRadius / (scaleFactor - initialMapScaleFactor + 1)
return [scaledRadius, setScaleFactor]
} and later in code const initialScaleFactor = 1.4
const [scaledMarkerRadius, setScaleFactor] = useStaticMapMarkerSize(markerRadius, initialScaleFactor)
//..
<ZoomableGroup
zoom={initialScaleFactor}
onMove={({ k }: { k: number }): void => setScaleFactor(k)}
>
// ..
{markers.map(({ name, coordinates, status }) => (
<Marker key={coordinates.toString()} coordinates={coordinates}>
<circle r={scaledMarkerRadius} />
</Marker>
))}
</ZoomableGroup> |
I used demo custom marker here: https://www.react-simple-maps.io/examples/custom-markers/ |
You can try scaling the corresponding attributes that modify the custom marker's position/size. On the element it would be something like: |
On a similar note, how do we make the marker stay at the coordinate as you zoom in/pan? |
I think that's what the |
Hi
Currently, On Zoom-in and Zoom-out, Marker size is changing accordingly. Is there a way to keep the marker size fixed, i.e it shouldn't change its size on zoom-in and zoom-out.
The text was updated successfully, but these errors were encountered: