---
title: Map Projection
source: https://vjmap.com/en/guide/mapProjection.html
---

# Map Projection

Map projection is divided into `GeoProjection` (geometric projection) and `LnglatProjection` (longitude-latitude projection) depending on the map basemap.

Projection is mainly used to convert `graphic geometry coordinates` to `longitude-latitude coordinates` for rendering.

## Geometric Projection with CAD as Basemap

```js
// Get map metadata
let metadata = await svc.metadata(mapid, "v1");
// Create a bounds object from the map bounds string
let mapBounds = vjmap.GeoBounds.fromString(metadata.bounds);
// Establish geometric projection coordinate system based on map bounds
let prj = new vjmap.GeoProjection(mapBounds);
// Get the center point geometry coordinates of the CAD map bounds
let center = mapBounds.center();
// Use the projection object to convert CAD geometry coordinates to longitude-latitude coordinates for rendering
let lngLat = prj.toLngLat(center);
// Create a marker based on these longitude-latitude coordinates and add it to the map
new vjmap.Marker().setLngLat(lngLat).addTo(map);
```

## Longitude-Latitude Projection with Internet Map as Basemap

For longitude-latitude projection with internet maps as the basemap, since internet maps already use longitude-latitude coordinates, the `longitude-latitude coordinates in the graphics` are consistent with the `longitude-latitude coordinates for rendering`.

```js
let prj = new vjmap.LnglatProjection();
let mapPoint = [106.31, 26.87];
let lngLat = prj.toLngLat(lngLat);
// lngLat output value is also [106.31, 26.87]
```
