[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:
- Instantiate MxMap and choose to pass in an existing McObject;
- Call setCoordinatePointAlign() to set the relationship between the map origin and CAD origin;
- Bind the mapbox instance through initMapbox();
- Call create (map, config) to start the integrated rendering of the map and CAD;
- 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
- cadLongToMercatorCoord
- cadToMercatorCoord
- cadTolnglat
- create
- getMapbox
- getMxDrawObject
- initMapbox
- lnglatToCAD
- lnglat_to_mercator
- map_lnglat_to_meters
- map_meters_to_lnglat
- mercatorCoord2CAD
- mercatorCoordToCAD
- mercator_to_lnglat
- outOfChina
- setCoordinatePointAlignment
- setLoadOldEditionMethod
Constructors
constructor
• new MxMap(inMxcad?)
Parameters
| Name | Type |
|---|---|
inMxcad? | McObject |
Properties
mxcad
• mxcad: McObject
MXCAD object
Methods
cadLongToMercatorCoord
▸ cadLongToMercatorCoord(len): number
Convert longitude coordinates to coordinates under Mercator projection
Parameters
| Name | Type | Description |
|---|---|---|
| Len | number | longitude |
Returns
number
Coordinates under Mercator projection
cadToMercatorCoord
▸ cadToMercatorCoord(pt): Vector3
CAD to Mapbox Mercator Coordinate System
Parameters
| Name | Type | Description |
|---|---|---|
| Pt | Vector3 | 3D point object |
Returns
Vector3
3D point object
cadTolnglat
▸ cadTolnglat(pt): number[]
Convert CAD coordinates to longitude and latitude
Parameters
| Name | Type | Description |
|---|---|---|
| Pt | Vector3 | 3D point object |
Returns
number[]
Latitude and longitude
create
▸ create(map, config): Promise<void>
Create a map
Parameters
| Name | Type | Description |
|---|---|---|
| Map | any | map object |
config | any | - |
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
| Name | Type | Description |
|---|---|---|
| Map | any | map object |
Returns
void
lnglatToCAD
▸ lnglatToCAD(lng, lat): Vector3
From latitude and longitude to CAD coordinates
Parameters
| Name | Type | Description |
|---|---|---|
| Lng | number | longitude |
| Lat | number | latitude |
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
| Name | Type | Description |
|---|---|---|
| Lng | number | longitude |
| Lat | number | dimension |
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
| Name | Type | Description |
|---|---|---|
| Lng | number | longitude |
| Lat | number | dimension |
Returns
number[]
Plane coordinates
map_meters_to_lnglat
▸ map_meters_to_lnglat(x, y): number[]
Map Mercator coordinate system to latitude and longitude
Parameters
| Name | Type | Description |
|---|---|---|
| X | number | X-axis coordinate |
| Y | number | Y-axis coordinate |
Returns
number[]
Latitude and longitude
mercatorCoord2CAD
▸ mercatorCoord2CAD(x, y): Vector3
MAPBOX's Mercator Coordinate System to CAD
Parameters
| Name | Type | Description |
|---|---|---|
| X | number | X-axis coordinate |
| Y | number | Y-axis coordinate |
Returns
Vector3
3D point object
mercatorCoordToCAD
▸ mercatorCoordToCAD(x, y): Vector3
MAPBOX's Mercator Coordinate System to CAD
Parameters
| Name | Type | Description |
|---|---|---|
| X | number | X-axis coordinate |
| Y | number | Y-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
| Name | Type | Description |
|---|---|---|
| X | number | X-axis coordinate |
| Y | number | Y-axis coordinate |
| Z | number | Z-axis coordinate |
Returns
number[]
Latitude and longitude
outOfChina
▸ outOfChina(lng, lat): boolean
Is it beyond the scope of China
Parameters
| Name | Type | Description |
|---|---|---|
| Lng | number | longitude |
| Lat | number | dimension |
Returns
boolean
Boolean value
setCoordinatePointAlignment
▸ setCoordinatePointAlignment(originLngLatLike, originCAD, meterInCADUnits): void
Set the alignment method of coordinate points
Parameters
| Name | Type | Description |
|---|---|---|
| OriginLngLatLike | number [] | Origin coordinates of longitude and latitude |
| OriginCAD | number [] | The starting point in the drawing coordinate system, which is the origin coordinate in AutoCAD |
| MeterInCADUnits | Number | Conversion 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
