Skip to main content

Geography

LngLat and LngLatBounds Represents point and polygon coordinates in the geographical world. .

LngLat

LngLat The object represents a specified latitude and longitude coordinate in degrees.
in order to communicate with GeoJSON Format matching,GL Use a coordinate sequence of longitude, latitude (instead of latitude, longitude). create Marker components.

new LngLat(lng: number, lat: number)

parameter

nametypedescribe
latNumberRequiredLatitude in degrees.
lngNumberRequiredLongitude in degrees.

Case

var ll = new mapmost.LngLat(-73.9749, 40.7736);

static members

convert

will contain an array of two numbers or have lng and lat or lon and lat The attribute object is converted to LngLat object. If passed is a LngLat object, the function returns it unchanged.

parameter
nametypedescribe
inputLngLatLikeRequiredAn array or object containing two numbers to be converted, or an array to be returned LngLat object.
Case
var arr = [-73.9749, 40.7736];
var ll = mapmost.LngLat.convert(arr);
ll; // = LngLat {longitude: -73.9749, latitude: 40.7736}

Instance members

toArray

Returns an array coordinate containing two numbers.

Case
  var ll = new mapmost.LngLat(-73.9749, 40.7736);
ll.toArray(); // = [-73.9749, 40.7736]

toBounds

Returns a coordinate position from the coordinate position to the specified extension boundary LngLatBounds。

parameter
NameTypeDefaultDescription
radiusNumber0OptionalThe distance in meters from the coordinate location to the extension boundary.
Case
  var ll = new mapmost.LngLat(-73.9749, 40.7736);
ll.toBounds(100).toArray(); // = [[-73.97501862141328, 40.77351016847229], [-73.97478137858673, 40.77368983152771]]

toString

Returns the coordinates as a string.

Case
  var ll = new mapmost.LngLat(-73.9749, 40.7736);
ll.toString(); // = "LngLat(-73.9749, 40.7736)"

wrap

Returns a longitude in (-180,180)new in range LngLat object.

Case
  var ll = new mapmost.LngLat(286.0251, 40.7736);
var wrapped = ll.wrap();
wrapped.lng; // = -73.9749

LngLatBounds

LngLatBounds The object represents a geographic bounding box, defined by southwest and northeast points represented by latitude and longitude.
If no parameters are provided to the constructor, create one null bounding box.

new LngLatBounds(sw: LngLatLike?, ne: LngLatLike?)

parameter

nametypedescribe
neLngLatLikeRequiredNortheast corner of the scope box.
swLngLatLikeRequiredSouthwest corner of the range box.

Case

var sw = new mapmost.LngLat(-73.9876, 40.7661);
var ne = new mapmost.LngLat(-73.9397, 40.8002);
var llb = new mapmost.LngLatBounds(sw, ne);

static members

convert

Convert array to LngLatBounds object.
If the parameter passed is a LngLatBounds object, the function returns it unchanged.
This function will be called internally LngLat#convert function that converts an array to LngLat value.
parameter
nametypedescribe
inputLngLatBoundsLikeRequiredAn array containing two coordinates to be converted, or an array to be returned LngLatBounds object.
Case
  var arr = [[-73.9876, 40.7661], [-73.9397, 40.8002]];
var llb = mapmost.LngLatBounds.convert(arr);
llb; // = LngLatBounds {_sw: LngLat {longitude: -73.9876, latitude: 40.7661}, _ne: LngLat {longitude: -73.9397, latitude: 40.8002}}

Instance members

extend

Extension boundaries include the specified LngLat or LngLatBounds。

parameter
nametypedescribe
objLngLat|LngLatBoundsRequiredObject that extends the bounds.
Case
const sw = new mapmost.LngLat(-73.9876, 40.7661);
const ne = new mapmost.LngLat(-73.9397, 40.8002);
const llb = new mapmost.LngLatBounds(sw, ne);
llb.extend([-72.9876, 42.2661]);

getCenter

Returns a geographic coordinate equidistant from the corners of the bounding box.

Case
  var llb = new mapmost.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.getCenter(); // = LngLat {longitude: -73.96365, latitude: 40.78315}

getEast

Returns the eastern boundary of the range box.

Case
const llb = new mapmost.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.getEast(); // -73.9397

getNorth

Returns the northern boundary of the range box.

Case
const llb = new mapmost.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.getNorth(); // 40.8002

getNorthEast

Returns the northeast corner of the range box.

Case
const llb = new mapmost.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.getNorthEast(); // LngLat {longitude: -73.9397, latitude: 40.8002}

getNorthWest

Returns the northwest corner of the range box.

Case
const llb = new mapmost.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.getNorthWest(); // LngLat {longitude: -73.9876, latitude: 40.8002}

getSouth

Returns the southern boundary of the range box.

Case
const llb = new mapmost.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.getSouth(); // 40.7661

getSouthEast

Returns the southeast corner of the range box.

Case
const llb = new mapmost.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.getSouthEast(); // LngLat {longitude: -73.9397, latitude: 40.7661}

getSouthWest

Returns the southwest corner of the range box.

Case
const llb = new mapmost.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.getSouthWest(); // LngLat {longitude: -73.9876, latitude: 40.7661}

getWest

Returns the western boundary of the range box.

Case
const llb = new mapmost.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.getWest(); // -73.9876

isEmpty

Check if the range box is empty.

Case
const llb = new mapmost.LngLatBounds();
llb.isEmpty(); // true
llb.setNorthEast([-73.9876, 40.7661]);
llb.setSouthWest([-73.9397, 40.8002]);
llb.isEmpty(); // false

setNorthEast

Sets the northeast corner of the range box.

parameter
nametypedescribe
neLngLatLikeRequiredNortheast corner of the scope box.
Case
const sw = new mapmost.LngLat(-73.9876, 40.7661);
const ne = new mapmost.LngLat(-73.9397, 40.8002);
const llb = new mapmost.LngLatBounds(sw, ne);
llb.setNorthEast([-73.9397, 42.8002]);

setSouthWest

Sets the southwest corner of the range box.

parameter
nametypedescribe
swLngLatLikeRequiredSouthwest corner of the range box.
Case
const sw = new mapmost.LngLat(-73.9876, 40.7661);
const ne = new mapmost.LngLat(-73.9397, 40.8002);
const llb = new mapmost.LngLatBounds(sw, ne);
llb.setSouthWest([-73.9876, 40.2661]);

toArray

Returns the range box represented as an array.

Case
var llb = new mapmost.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.toArray(); // = [[-73.9876, 40.7661], [-73.9397, 40.8002]]

toString

Returns the range box as a string.

Case
var llb = new mapmost.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.toString(); // = "LngLatBounds(LngLat(-73.9876, 40.7661), LngLat(-73.9397, 40.8002))"

LngLatBoundsLike

one LngLatBounds object, or a LngLatLike array of objects with [Southwest, Northeast] is the sequence, it can also be an array of numbers with [west, south, east, north] for the order.

Case

var v1 = new mapmost.LngLatBounds(
new mapmost.LngLat(-73.9876, 40.7661),
new mapmost.LngLat(-73.9397, 40.8002)
);
var v2 = new mapmost.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002])
var v3 = [[-73.9876, 40.7661], [-73.9397, 40.8002]];

LngLatLike

one LngLat object, or an array of two numbers representing longitude and latitude, or an array with lng and lat or lon and lat properties object.

Case

var v1 = new mapmost.LngLat(-122.420679, 37.772537);
var v2 = [-122.420679, 37.772537];
var v3 = {lon: -122.420679, lat: 37.772537};

MercatorCoordinate

one MercatorCoordinate Instance represents a three-dimensional projected coordinate.
MercatorCoordinate use Web Mercator projection (EPSG:3857) ,But the unit handling is slightly different:

  • unit1Represents the width of the projected world rather than the meters in originally defined Mercator coordinates
  • The origin of the coordinate space is the northwest corner instead of the original center point
new MercatorCoordinate(x: number, y: number, z: number)

parameter

NameTypeDefaultDescription
xNumberRequiredxposition on the axis.
yNumberRequiredyposition on the axis.
zNumber0Optionalzposition on the axis.

Case

var nullIsland = new mapmost.MercatorCoordinate(0.5, 0.5, 0);

static members

fromLngLat

Will LngLat Projection converted to MercatorCoordinate。

parameter
NameTypeDefaultDescription
lngLatLikeLngLatLikeRequiredThe latitude and longitude to be converted.
altitudeNumber0OptionalThe altitude of this location, in meters.
Case
var coord = mapmost.MercatorCoordinate.fromLngLat({ lng: 0, lat: 0}, 0);
coord; // MercatorCoordinate(0.5, 0.5, 0)

Instance members

toAltitude

Returns the altitude of this coordinate in meters.

Case
var coord = new mapmost.MercatorCoordinate(0, 0, 0.02);
coord.toAltitude(); // 6914.281956295339

toLngLat

Returns the latitude and longitude of this coordinate LngLat 。

Case
var coord = new mapmost.MercatorCoordinate(0.5, 0.5, 0);
var latLng = coord.toLngLat(); // Latitude and longitude coordinates (0, 0)