Methods
| Method | Returns | Description |
|---|---|---|
latLngToPoint(<LatLng>
|
Point |
Projects geographical coordinates into pixel coordinates for a given zoom.
将地理坐标投影为给定缩放的像素坐标。 |
pointToLatLng(<Point>
|
LatLng |
The inverse of latLngToPoint. Projects pixel coordinates on a given zoom into geographical coordinates.
latLngToPoint的倒数。将给定缩放的像素坐标投影为地理坐标。 |
project(<LatLng> latlng) |
Point |
Projects geographical coordinates into coordinates in units accepted for this CRS (e.g. meters for EPSG:3857, for passing it to WMS services).
将地理坐标投影为该CRS接受的单位坐标(例如EPSG:3857的米,用于传递给WMS服务)。 |
unproject(<Point> point) |
LatLng |
Given a projected coordinate returns the corresponding LatLng. The inverse of project.
给定投影坐标,返回相应的LatLng。项目的倒数。 |
scale(<Number> zoom) |
Number |
Returns the scale used when transforming projected coordinates into pixel coordinates for a particular zoom. For example, it returns 256 * 2^zoom for Mercator-based CRS.
返回将投影坐标转换为特定缩放的像素坐标时使用的比例。例如,它为基于墨卡托的CRS返回256*2^缩放。 |
zoom(<Number> scale) |
Number |
Inverse of scale(), returns the zoom level corresponding to a scale factor of scale.
逆比例(),返回与比例因子相对应的缩放级别。 |
getProjectedBounds
|
Bounds |
Returns the projection’s bounds scaled and transformed for the provided zoom.
返回为提供的缩放缩放缩放和变换的投影边界。 |
distance(<LatLng>
|
Number |
Returns the distance between two geographical coordinates. |
wrapLatLng(<LatLng> latlng) |
LatLng |
Returns a LatLng where lat and lng has been wrapped according to the CRS’s wrapLat and wrapLng properties, if they are outside the CRS’s bounds.
返回LatLng,其中lat和lng已根据CRS的wrapLat和wrapLng属性进行了包装,如果它们在CRS的边界之外。 |
wrapLatLngBounds(<
|
LatLngBounds |
Returns a LatLngBounds with the same size as the given one, ensuring that its center is within the CRS’s bounds. Only accepts actual L.LatLngBounds instances, not arrays.
返回与给定大小相同的LatLngBounds,确保其中心在CRS的范围内。仅接受实际的L.LatLngBounds实例,而不接受数组。 |
Properties
| Property | Type | Description |
|---|---|---|
code |
String |
Standard code name of the CRS passed into WMS services (e.g. 'EPSG:3857')
传递到WMS服务的CRS的标准代码名称(例如“EPSG:3857”) |
wrapLng |
Number[] |
An array of two numbers defining whether the longitude (horizontal) coordinate axis wraps around a given range and how. Defaults to [-180, 180] in most geographical CRSs. If undefined, the longitude axis does not wrap around.
一个由两个数字组成的数组,定义经度(水平)坐标轴是否环绕给定范围以及如何环绕。在大多数地理CRS中默认为[-180,180]。如果未定义,则经度轴不会环绕。 |
wrapLat |
Number[] |
Like wrapLng, but for the latitude (vertical) axis.
类似于wrapLng,但用于纬度(垂直)轴。 |
infinite |
Boolean |
If true, the coordinate space will be unbounded (infinite in both axes)
如果为真,坐标空间将是无限的(在两个轴上都是无限的) |
Defined CRSs
| CRS | Description |
|---|---|
L.CRS.Earth |
Serves as the base for CRS that are global such that they cover the earth. Can only be used as the base for other CRS and cannot be used directly, since it does not have a code, projection or transformation. distance() returns meters.
作为CRS的基础,CRS是全球性的,覆盖了地球。只能用作其他CRS的基础,不能直接使用,因为它没有代码、投影或转换。distance()返回米。 |
L.CRS.EPSG3395 |
Rarely used by some commercial tile providers. Uses Elliptical Mercator projection.
一些商业瓷砖供应商很少使用。使用椭圆墨卡托投影。 |
L.CRS.EPSG3857 |
The most common CRS for online maps, used by almost all free and commercial tile providers. Uses Spherical Mercator projection. Set in by default in Map’s crs option.
在线地图最常见的CRS,几乎所有免费和商业瓷砖供应商都使用。使用球面墨卡托投影。默认情况下,在Map的crs选项中设置。 |
L.CRS.EPSG4326 |
A common CRS among GIS enthusiasts. Uses simple Equirectangular projection.Leaflet 1.0.x complies with the TMS coordinate scheme for EPSG:4326, which is a breaking change from 0.7.x behaviour. If you are using a TileLayer with this CRS, ensure that there are two 256×256 pixel tiles covering the whole earth at zoom level zero, and that the tile coordinate origin is (-180,+90), or (-180,-90) for TileLayers with the tms option set.
GIS爱好者中常见的CRS。使用简单的等矩形投影。传单1.0.x符合EPSG:4326的TMS坐标方案,这是从0.7.x行为的突破性变化。如果您将TileLayer与此CRS一起使用,请确保有两个256×256像素的平铺,以零缩放级别覆盖整个地球,并且平铺坐标原点对于设置了tms选项的TileLayers为(-180、+90)或(-180和-90)。 |
L.CRS.Base |
Object that defines coordinate reference systems for projecting geographical points into pixel (screen) coordinates and back (and to coordinates in other units for WMS services). See spatial reference system.Leaflet defines the most usual CRSs by default. If you want to use a CRS not defined by default, take a look at the Proj4Leaflet plugin.
Note that the CRS instances do not inherit from Leaflet’s 定义坐标参考系统的对象,用于将地理点投影到像素(屏幕)坐标和背面(以及WMS服务的其他单位坐标)。参见空间参考系。传单默认定义了最常用的CRS。如果您想使用默认情况下未定义的CRS,请查看Proj4Leaflet插件。请注意,CRS实例不是从Leaflet的Class对象继承的,并且不能实例化。此外,新类不能从它们继承,方法也不能用include函数添加到它们中。 |
L.CRS.Simple |
A simple CRS that maps longitude and latitude into x and y directly. May be used for maps of flat surfaces (e.g. game maps). Note that the y axis should still be inverted (going from bottom to top). distance() returns simple euclidean distance.
一个简单的CRS,将经度和纬度直接映射到x和y。可用于平面地图(例如游戏地图)。请注意,y轴仍然应该反转(从下到上)。distance()返回简单的欧氏距离。 |