Set react-leaflet map CRS atribute

六月ゝ 毕业季﹏ 提交于 2019-12-08 05:28:24

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/48185208/set-react-leaflet-map-crs-atribute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!