# Class: GeoProjection
GeoProjection
地理坐标投影.
Example:
const mapExtent = new GeoBounds(new GeoPoint(10, 20), new GeoPoint(80, 90));
const prj = new GeoProjection(mapExtent);
const pt = [30, 30];
const latlng = prj.toLngLat(pt);
const pt_geo = prj.fromLngLat(latlng);
const mkt = prj.toMercator(pt);
const pt_mkt = prj.fromMercator(mkt);
2
3
4
5
6
7
# Hierarchy
-
↳ GeoProjection
# Table of contents
# Constructors
# Properties
# Methods
- fromLngLat
- fromMercator
- fromMeter
- getMapExtent
- setExtent
- toLngLat
- toMercator
- toMeter
- lngLat2Mercator
- mercator2LngLat
# Constructors
# constructor
+ new GeoProjection(extent
: GeoBounds): GeoProjection
GeoBounds
构造函数
extent
extent - 地图地理范围.
# Parameters
Name | Type |
---|---|
extent | GeoBounds |
Returns: GeoProjection
Overrides: Projection
# Properties
# mapExtent
• mapExtent: GeoBounds
地图地理范围.
# EARTH_BOUNDS
▪ Static
EARTH_BOUNDS: [number, number, number, number]
The equatorial semi perimeter in meters.
Inherited from: Projection.EARTH_BOUNDS
# EQUATORIAL_SEMIPERIMETER
▪ Static
EQUATORIAL_SEMIPERIMETER: number= 20037508.3427892
The equatorial semi perimeter in meters.
Inherited from: Projection.EQUATORIAL_SEMIPERIMETER
# Methods
# fromLngLat
▸ fromLngLat(input
: GeoPoint | Feature<Geometry | GeometryCollection, Properties> | FeatureCollection<Geometry | GeometryCollection, Properties> | Geometry | GeometryCollection | [number, number] | [number, number, number] | { x
: number ; y
: number ; z?
: number } | { lat
: number ; lng
: number } | { lat
: number ; lon
: number } | GeoPointLike[]): GeoPoint | Feature<Geometry | GeometryCollection, Properties> | FeatureCollection<Geometry | GeometryCollection, Properties> | Geometry | GeometryCollection | [number, number] | [number, number, number] | { x
: number ; y
: number ; z?
: number } | { lat
: number ; lng
: number } | { lat
: number ; lon
: number } | GeoPointLike[]
经纬度转地图地理坐标
# Parameters
Name | Type | Description |
---|---|---|
input | GeoPoint | Feature<Geometry | GeometryCollection, Properties> | FeatureCollection<Geometry | GeometryCollection, Properties> | Geometry | GeometryCollection | [number, number] | [number, number, number] | { x : number ; y : number ; z? : number } | { lat : number ; lng : number } | { lat : number ; lon : number } | GeoPointLike[] | 经纬度坐标点 |
Returns: GeoPoint | Feature<Geometry | GeometryCollection, Properties> | FeatureCollection<Geometry | GeometryCollection, Properties> | Geometry | GeometryCollection | [number, number] | [number, number, number] | { x
: number ; y
: number ; z?
: number } | { lat
: number ; lng
: number } | { lat
: number ; lon
: number } | GeoPointLike[]
Overrides: Projection
# fromMercator
▸ fromMercator(input
: GeoPointLike): [number, number]
墨卡托(epsg:3857)转坐标
# Parameters
Name | Type | Description |
---|---|---|
input | GeoPointLike | 墨卡托坐标点 |
Returns: [number, number]
Overrides: Projection
# fromMeter
▸ fromMeter(meter
: number): number
把米转化为距离
# Parameters
Name | Type |
---|---|
meter | number |
Returns: number
Overrides: Projection
# getMapExtent
▸ getMapExtent(): GeoBounds
得到地图范围
Returns: GeoBounds
Overrides: Projection
# setExtent
▸ setExtent(extent
: GeoBounds): void
设置地图范围
extent
extent - 地图地理范围.
# Parameters
Name | Type |
---|---|
extent | GeoBounds |
Returns: void
# toLngLat
▸ toLngLat(input
: GeoPoint | Feature<Geometry | GeometryCollection, Properties> | FeatureCollection<Geometry | GeometryCollection, Properties> | Geometry | GeometryCollection | [number, number] | [number, number, number] | { x
: number ; y
: number ; z?
: number } | { lat
: number ; lng
: number } | { lat
: number ; lon
: number } | GeoPointLike[]): LngLatLike
地图地理坐标转经纬度
# Parameters
Name | Type | Description |
---|---|---|
input | GeoPoint | Feature<Geometry | GeometryCollection, Properties> | FeatureCollection<Geometry | GeometryCollection, Properties> | Geometry | GeometryCollection | [number, number] | [number, number, number] | { x : number ; y : number ; z? : number } | { lat : number ; lng : number } | { lat : number ; lon : number } | GeoPointLike[] | 地理坐标点 |
Returns: LngLatLike
Overrides: Projection
# toMercator
▸ toMercator(input
: GeoPointLike): [number, number]
坐标转墨卡托(epsg:3857)
# Parameters
Name | Type | Description |
---|---|---|
input | GeoPointLike | 坐标点 |
Returns: [number, number]
Overrides: Projection
# toMeter
▸ toMeter(dist
: number): number
把距离转化为米
# Parameters
Name | Type |
---|---|
dist | number |
Returns: number
Overrides: Projection
# lngLat2Mercator
▸ Static
lngLat2Mercator(input
: GeoPointLike): [number, number]
经纬度转墨卡托 .
# Parameters
Name | Type |
---|---|
input | GeoPointLike |
Returns: [number, number]
Inherited from: Projection
# mercator2LngLat
▸ Static
mercator2LngLat(input
: GeoPointLike): [number, number]
墨卡托转经纬度 .
# Parameters
Name | Type |
---|---|
input | GeoPointLike |
Returns: [number, number]
Inherited from: Projection