@yandex/ymaps3-cartesian-projection
v0.0.6
Published
Yandex Maps JS API 3.0 example @yandex/ymaps3-cartesian-projection
Downloads
34
Readme
@yandex/ymaps3-cartesian-projection package
Yandex JS API package
This package will project your cartesian dimensions to Yandex JS API world representation (see scheme of work below). Then you can use it as YMap location property, in YMapListener handlers, etc.

Install
You can install this package via npm:
npm install --save @yandex/ymaps3-cartesian-projectionHow use
To use Cartesian projection, just import it:
import {Cartesian} from '@yandex/ymaps3-cartesian-projection';
const projection = new Cartesian([
// these boundaries define the limits of the world map in the Cartesian coordinate system.
[-400, -600],
[400, 600],
]);
console.log(projection.toWorldCoordinates([-400, 600])) // {x: -1, y: 1}
console.log(projection.toWorldCoordinates([200, 0])) // {x: 0.5, y: 0}
console.log(projection.toWorldCoordinates([0, -75])) // {x: 0, y: -0.125}
console.log(projection.fromWorldCoordinates({x: -1, y: 1})) // [-400, 600]
console.log(projection.fromWorldCoordinates({x: 0.5, y: 0})) // [200, 0]
console.log(projection.fromWorldCoordinates({x: 0, y: -0.125})) // [0, -75]Usage without npm
You can use CDN with module loading handler in JS API on your page.
By default ymaps3.import can load self modules.
Just use ymaps3.registerCdn and ymaps3.import:
// register in `ymaps3.import` which CDN to take the package from
ymaps3.import.registerCdn('https://cdn.jsdelivr.net/npm/{package}', '@yandex/ymaps3-cartesian-projection@latest');
// ...
// import package from CDN
await ymaps3.ready;
const {Cartesian} = await ymaps3.import('@yandex/ymaps3-cartesian-projection');