Projection package spherical-mercator-projection

Interface: GenericProjection<TSource>

Type parameters

Name
TSource

Properties

type

optional readonly type: string

Projection identity type. It may be:

  • EPSG-code (e.g. EPSG:3857)
  • any other string to identify (e.g. 'cartesian')

Methods

fromWorldCoordinates

fromWorldCoordinates(coordinates): TSource

Parameters
Name Type
coordinates WorldCoordinates
Returns

TSource


toWorldCoordinates

toWorldCoordinates(point): WorldCoordinates

Parameters
Name Type
point TSource
Returns

WorldCoordinates

Interface: Vec2

Properties

x

x: number

y

y: number

Interface: WorldCoordinates

Coordinates in [-1 ... +1].
Left bottom is (-1; -1).
Right top is (+1; +1).
Center is (0; 0).

Properties

type

optional readonly type: "world"

x

x: number
Inherited from

Vec2.x


y

y: number
Inherited from

Vec2.y


z

optional z: number

Variables

SphericalMercator

const SphericalMercator: () => Projection
Type declaration

()

Name

projection.sphericalMercator

Static

Deprecated

Use Web Mercator package instead.

Example

const {SphericalMercator} = await mappable.import('@mappable-world/mappable-spherical-mercator-projection@0.0.1');
// Create a map in the spherical Mercator projection
const map = new mappable.MMap(document.getElementById('MMapsID'), {
    location: {
        center: [37, 55],
         zoom: 6
    },
    projection: new SphericalMercator()
});
const dataSourceProps = {
    raster: {
        type: 'ground',
        fetchTile: "https://tile.openstreetmap.org/z/y/x"
    }
};
// Add osm tiles
const dataSource = new mappable.MMapTileDataSource({
    id: "osmSource",
    ...dataSourceProps,
});

const layer = new mappable.MMapLayer({
    id: "osm",
    source: "osmSource",
    type: "ground",
});

Module: <internal>

Type Aliases

LngLat

LngLat: [lon: number, lat: number, alt?: number]

Tuple with geodesic coordinates in longitude latitude order.
GeoJSON also uses this order https://tools.ietf.org/html/rfc7946#appendix-A.1


Projection

Projection: GenericProjection<LngLat>