Yandex Maps JS API 3.0 example @yandex/ymaps3-cartesian-projection
npm install @yandex/ymaps3-cartesian-projectionYandex 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.
You can install this package via npm:
``bash`
npm install --save @yandex/ymaps3-cartesian-projection
To use Cartesian projection, just import it:
`js
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]
`
You can use CDN with module loading handler in JS API on your page.
By default ymaps3.import can load self modules.ymaps3.registerCdn
Just use and ymaps3.import:
`jsymaps3.import
// register in 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');
``