设置react-leaflet映射CRS属性 [英] Set react-leaflet map CRS atribute

查看:485
本文介绍了设置react-leaflet映射CRS属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在本机Leaflet映射中,lib CRS属性应设置如下

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,
});

如何在react-leaflet中做到这一点,我尝试了一些事情,但没有成功:/

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>

但是存在未导入CRS的错误. 如何导入CRS?

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

我在哪里错了?

推荐答案

我需要从本机传单中导入CRS.

I need to import CRS from native leaflet.

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

,然后在 MAP 组件中

and then in MAP component

 <Map center={[0, 0]} zoom={2}  doubleClickZoom={false} crs={CRS.Simple}>
    ...
 </Map

这篇关于设置react-leaflet映射CRS属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆