diff --git a/rendering/cases/layer-vector-multi-world/expected.png b/rendering/cases/layer-vector-multi-world/expected.png new file mode 100644 index 0000000000..908c05a4a2 Binary files /dev/null and b/rendering/cases/layer-vector-multi-world/expected.png differ diff --git a/rendering/cases/layer-vector-multi-world/main.js b/rendering/cases/layer-vector-multi-world/main.js new file mode 100644 index 0000000000..ae458e87fe --- /dev/null +++ b/rendering/cases/layer-vector-multi-world/main.js @@ -0,0 +1,69 @@ +import Feature from '../../../src/ol/Feature.js'; +import Fill from '../../../src/ol/style/Fill.js'; +import Map from '../../../src/ol/Map.js'; +import Polygon from '../../../src/ol/geom/Polygon.js'; +import Style from '../../../src/ol/style/Style.js'; +import VectorLayer from '../../../src/ol/layer/Vector.js'; +import VectorSource from '../../../src/ol/source/Vector.js'; +import View from '../../../src/ol/View.js'; +import {Projection, addCoordinateTransforms} from '../../../src/ol/proj.js'; +import {fromEPSG4326, toEPSG4326} from '../../../src/ol/proj/epsg3857.js'; + +const projection = new Projection({ + code: 'custom', + units: 'm', + global: true, + extent: [-40075016.68557849, -20037508.342789244, 0, 20037508.342789244], +}); + +addCoordinateTransforms( + 'EPSG:4326', + projection, + function (coord) { + const converted = fromEPSG4326(coord); + converted[0] -= 20037508.342789244; + return converted; + }, + function (coord) { + return toEPSG4326([coord[0] + 20037508.342789244, coord[1]]); + } +); + +const feature = new Feature({ + geometry: new Polygon([ + [ + [-20037508.342789244, 20037508.342789244], + [-20037508.342789244, -20037508.342789244], + [-16037508.342789244, -20037508.342789244], + [-16037508.342789244, 20037508.342789244], + [-20037508.342789244, 20037508.342789244], + ], + ]), +}); + +new Map({ + pixelRatio: 1, + layers: [ + new VectorLayer({ + renderBuffer: 0, + source: new VectorSource({ + features: [feature], + }), + style: new Style({ + fill: new Fill({ + color: 'black', + }), + }), + }), + ], + target: 'map', + view: new View({ + projection: projection, + multiWorld: true, + maxResolution: 485254.1017841229, + zoom: 0, + center: [2000000, 0], + }), +}); + +render();