2

I am trying to create a map, but for some reason multiple maps are being displayed. I am not sure what is causing this.

App.js:

import { MapContainer, Marker, Popup, TileLayer } from "react-leaflet";
const position = [51.505, -0.09]

function Map() {
  return (
    <div className="map">
      <MapContainer
        center={position}
        zoom={100}
        scrollWheelZoom={false}
      >
        <TileLayer
          attribution='Some random text'
          url="http://blog.damonpollard.com/wp-content/uploads/2013/09/GTAV_ATLUS_4096x4096.png"
        />
        <Marker position={position}>
          <Popup>
            A pretty CSS3 popup. <br /> Easily customizable.
          </Popup>
        </Marker>
      </MapContainer>
    </div >
  );
}

export default Map;

index.css:

.leaflet-container {
  width: 100%;
  height: 100vh;
}

Here is how the map looks

1 Answer 1

1

If you have a single (non tiled) image as map, use it as an Image Overlay instead of as a Tile Layer.

Sign up to request clarification or add additional context in comments.

3 Comments

```js <ImageOverlay attribution="Some text" url="blog.damonpollard.com/wp-content/uploads/2013/09/…" bounds={[[0, 0], [4096, 4096]]} /> ```` The map isn't displaying anymore. I only see a white screen with the marker.
With these image bounds, I am guessing your zoom becomes an issue. What if you set zoom to -3 for example?
Setting the zoom to -1 and adjusting the bounds a bit worked for me. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.