Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert removal of M.geojson2mapml and M.mapml2geojson public API methods #985

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/mapml/GlobalM.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,9 @@ import './handlers/keyboard';
}
});

M.geojson2mapml = Util.geojson2mapml;
M.mapml2geojson = Util.mapml2geojson;

// see https://leafletjs.com/examples/extending/extending-3-controls.html#handlers
L.Map.addInitHook('addHandler', 'query', QueryHandler);
L.Map.addInitHook('addHandler', 'contextMenu', ContextMenu);
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/geojson/geojson2mapml.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<body>
<!--geojson2mapml layer output goes here dynamically-->
<mapml-viewer id="output" projection="OSMTILE" zoom="10" lon="-75.7" lat="45.4" controls>
<mapml-viewer data-testid="map" id="output" projection="OSMTILE" zoom="10" lon="-75.7" lat="45.4" controls>
</mapml-viewer>

<!-- The expected results for geojson2mapml go here-->
Expand Down
11 changes: 11 additions & 0 deletions test/e2e/geojson/geojson2mapml.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,15 @@ test.describe('GeoJSON API - geojson2mapml', () => {
);
expect(out).toEqual(exp);
});
test('M.geojson2mapml public API method exists and works', async ()=>{
const viewer = page.getByTestId('map');
await viewer.evaluate((v)=>{
let l = M.geojson2mapml(point, {label: 'M.geojson2mapml public API method works'});
v.appendChild(l);
l.setAttribute('data-testid','test-layer');
});
const layer = page.getByTestId('test-layer');
await expect(layer).not.toHaveAttribute('disabled');
await expect(layer).toHaveAttribute('label','M.geojson2mapml public API method works');
});
});
2 changes: 1 addition & 1 deletion test/e2e/geojson/mapml2geojson.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<!--All the mapml layers- that will be converted to geojson go in the mapml-viewer-->
<mapml-viewer projection="OSMTILE" zoom="10" lon="-75.7" lat="45.4" controls>

<layer- label="Point Geometry" checked>
<layer- data-testid="point" label="Point Geometry" checked>
<map-feature>
<map-featurecaption>Point</map-featurecaption>
<map-geometry>
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/geojson/mapml2geojson.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,11 @@ test.describe('GeoJSON API - mapml2geojson', () => {
);
expect(out10).toEqual(exp10);
});
test('M.mapml2geojson public API method exists and works', async () => {
const geojsonPoint = await page.evaluate(() => {
let layer = document.querySelector('[data-testid=point]');
return M.mapml2geojson(layer);
});
expect(geojsonPoint.title).toEqual('Point Geometry');
});
});