Skip to content

[mxcad_2d API documentation] (../README. md)/[mapbox] (../modules/mapbox. md)/MxMap

Class: MxMap ​

mapbox.MxMap

Mapbox map and CAD coordinate system bridging class, used to convert map coordinates and CAD drawing coordinates to each other.

Description

MxMap is a bridging object used to connect Mapbox maps and MxCAD/AutoCAD coordinate systems, mainly used for collaborative work with CAD drawings in geographic map scenes. It is capable of completing: -Bind Mapbox map instance; -Convert between latitude and longitude, Mercator coordinates, and CAD coordinates; -Handling map scaling and aligning CAD coordinate systems; -Generate custom map layers using the creat() method and integrate them into the CAD rendering environment; -Adapt to the creation methods of old and new versions of maps.

Usage:

  1. Instantiate MxMap and choose to pass in an existing McObject;
  2. Call setCoordinatePointAlign() to set the relationship between the map origin and CAD origin;
  3. Bind the mapbox instance through initMapbox();
  4. Call create (map, config) to start the integrated rendering of the map and CAD;
  5. Use methods such as lnglatToCAD() and mercatorCoord2CAD() to perform coordinate transformation.

Summary: MxMap is a core tool that connects map geographic coordinates with CAD drawing coordinates, suitable for collaborative display scenarios of geographic information, map positioning, surveying data, and engineering drawings.

Table of contents ​

Constructors ​

Properties ​

Methods ​

Constructors ​

constructor ​

• new MxMap(inMxcad?)

Parameters ​

NameType
inMxcad?McObject

Properties ​

mxcad ​

• mxcad: McObject

MXCAD object

Methods ​

cadLongToMercatorCoord ​

▸ cadLongToMercatorCoord(len): number

Convert longitude coordinates to coordinates under Mercator projection

Parameters ​

NameTypeDescription
Lennumberlongitude

Returns ​

number

Coordinates under Mercator projection


cadToMercatorCoord ​

▸ cadToMercatorCoord(pt): Vector3

CAD to Mapbox Mercator Coordinate System

Parameters ​

NameTypeDescription
PtVector33D point object

Returns ​

Vector3

3D point object


cadTolnglat ​

▸ cadTolnglat(pt): number[]

Convert CAD coordinates to longitude and latitude

Parameters ​

NameTypeDescription
PtVector33D point object

Returns ​

number[]

Latitude and longitude


create ​

▸ create(map, config): Promise<void>

Create a map

Parameters ​

NameTypeDescription
Mapanymap object
configany-

Returns ​

Promise<void>


getMapbox ​

▸ getMapbox(): any

Get the map object of mapbox

Returns ​

any

Map object


getMxDrawObject ​

▸ getMxDrawObject(): MxDrawObject

Retrieve the current mxdraw object

Returns ​

MxDrawObject

Mxdraw object


initMapbox ​

▸ initMapbox(map): void

Initialize mapbox

Parameters ​

NameTypeDescription
Mapanymap object

Returns ​

void


lnglatToCAD ​

▸ lnglatToCAD(lng, lat): Vector3

From latitude and longitude to CAD coordinates

Parameters ​

NameTypeDescription
Lngnumberlongitude
Latnumberlatitude

Returns ​

Vector3

3D point object


lnglat_to_mercator ​

▸ lnglat_to_mercator(lng, lat): Vector3

Coordinate from latitude and longitude to the Mercator coordinate system of Mapbox

Parameters ​

NameTypeDescription
Lngnumberlongitude
Latnumberdimension

Returns ​

Vector3

3D point object


map_lnglat_to_meters ​

▸ map_lnglat_to_meters(lng, lat): number[]

Convert the coordinates (longitude and latitude) in the geographic coordinate system to the coordinates (meters) in the planar coordinate system

Parameters ​

NameTypeDescription
Lngnumberlongitude
Latnumberdimension

Returns ​

number[]

Plane coordinates


map_meters_to_lnglat ​

▸ map_meters_to_lnglat(x, y): number[]

Map Mercator coordinate system to latitude and longitude

Parameters ​

NameTypeDescription
XnumberX-axis coordinate
YnumberY-axis coordinate

Returns ​

number[]

Latitude and longitude


mercatorCoord2CAD ​

▸ mercatorCoord2CAD(x, y): Vector3

MAPBOX's Mercator Coordinate System to CAD

Parameters ​

NameTypeDescription
XnumberX-axis coordinate
YnumberY-axis coordinate

Returns ​

Vector3

3D point object


mercatorCoordToCAD ​

▸ mercatorCoordToCAD(x, y): Vector3

MAPBOX's Mercator Coordinate System to CAD

Parameters ​

NameTypeDescription
XnumberX-axis coordinate
YnumberY-axis coordinate

Returns ​

Vector3

3D point object


mercator_to_lnglat ​

▸ mercator_to_lnglat(x, y, z): number[]

Mapbox's Mercator coordinate system to latitude and longitude

Parameters ​

NameTypeDescription
XnumberX-axis coordinate
YnumberY-axis coordinate
ZnumberZ-axis coordinate

Returns ​

number[]

Latitude and longitude


outOfChina ​

▸ outOfChina(lng, lat): boolean

Is it beyond the scope of China

Parameters ​

NameTypeDescription
Lngnumberlongitude
Latnumberdimension

Returns ​

boolean

Boolean value


setCoordinatePointAlignment ​

▸ setCoordinatePointAlignment(originLngLatLike, originCAD, meterInCADUnits): void

Set the alignment method of coordinate points

Parameters ​

NameTypeDescription
OriginLngLatLikenumber []Origin coordinates of longitude and latitude
OriginCADnumber []The starting point in the drawing coordinate system, which is the origin coordinate in AutoCAD
MeterInCADUnitsNumberConversion between Geographic Coordinate Systems and Coordinate Units Used in AutoCAD Drawing

Returns ​

void


setLoadOldEditionMethod ​

▸ setLoadOldEditionMethod(): void

Used to set up loading of old version maps

Returns ​

void