OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Resizing a Map with react-simple-maps in React

  • Thread starter Thread starter Yasha_ops
  • Start date Start date
Y

Yasha_ops

Guest
I'm attempting to display a map of France using react-simple-maps. However, I'm encountering an issue where the map appears too small. Despite trying various methods such as CSS adjustments, modifying width and height attributes and using ZoomableGroup, I haven't been able to scale it up successfully. Could someone assist me in resolving this issue?

Here's my code:

Code:
import { Page } from "@/components/ui/page";
import {
  ComposableMap,
  Geographies,
  Geography,
  ZoomableGroup,
} from "react-simple-maps";

const geoUrl =
  "https://france-geojson.gregoiredavid.fr/repo/departements.geojson";

export default () => {
  return (
    <Page className="gap-10 w-full">
      <Page.Header className="flex flex-col gap-4 items-start">
        <h1 className="mt-[70px] text-3xl">Carte</h1>
        <h2 className="text-xs text-dark opacity-65">Carte des departements</h2>
      </Page.Header>

      <Page.Body>
        <ComposableMap
          projectionConfig={{
            scale: 155,
          }}
          width={800}
          height={400}
          style={{ width: "100%", height: "auto" }}
        >
          <ZoomableGroup disablePanning zoom={1}>
            <Geographies geography={geoUrl}>
              {({ geographies }) =>
                geographies.map((geo) => (
                  <Geography key={geo.rsmKey} geography={geo} />
                ))
              }
            </Geographies>
          </ZoomableGroup>
        </ComposableMap>
      </Page.Body>
    </Page>
  );
};

Here's the image: enter image description here

<p>I'm attempting to display a map of France using react-simple-maps. However, I'm encountering an issue where the map appears too small. Despite trying various methods such as CSS adjustments, modifying width and height attributes and using ZoomableGroup, I haven't been able to scale it up successfully. Could someone assist me in resolving this issue?</p>
<p>Here's my code:</p>
<pre><code>import { Page } from "@/components/ui/page";
import {
ComposableMap,
Geographies,
Geography,
ZoomableGroup,
} from "react-simple-maps";

const geoUrl =
"https://france-geojson.gregoiredavid.fr/repo/departements.geojson";

export default () => {
return (
<Page className="gap-10 w-full">
<Page.Header className="flex flex-col gap-4 items-start">
<h1 className="mt-[70px] text-3xl">Carte</h1>
<h2 className="text-xs text-dark opacity-65">Carte des departements</h2>
</Page.Header>

<Page.Body>
<ComposableMap
projectionConfig={{
scale: 155,
}}
width={800}
height={400}
style={{ width: "100%", height: "auto" }}
>
<ZoomableGroup disablePanning zoom={1}>
<Geographies geography={geoUrl}>
{({ geographies }) =>
geographies.map((geo) => (
<Geography key={geo.rsmKey} geography={geo} />
))
}
</Geographies>
</ZoomableGroup>
</ComposableMap>
</Page.Body>
</Page>
);
};

</code></pre>
<p>Here's the image:
<a href="https://i.sstatic.net/BJeIr.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/BJeIr.png" alt="enter image description here" /></a></p>
 

Latest posts

Top