Set react-leaflet map CRS atribute
Asked Answered
B

1

6

In native Leaflet map, lib CRS attribute should be set as below

var mymap = L.map('mapid', {
    center: [-1800, 1000],
    zoom: 13,
    crs: L.CRS.Simple,
    minZoom: 0,
    maxZoom: 13,
});

How to do that in react-leaflet, I had tried some things but nothing successful :/

    <Map crs={CRS.useSimple()} center={[-1800, 1000]} zoom={13} doubleClickZoom={false} >

    </Map>

But there is an error that CRS is not imported. How to import CRS?

Where do I wrong?

Bateau answered 10/1, 2018 at 10:25 Comment(0)
B
16

I need to import CRS from native leaflet.

import React, { Component } from 'react';
import {Map} from 'react-leaflet'
import {CRS} from 'leaflet';

and then in MAP component

 <Map center={[0, 0]} zoom={2}  doubleClickZoom={false} crs={CRS.Simple}>
    ...
 </Map
Bateau answered 10/1, 2018 at 14:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.