Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
defbef0
change default cs from pcrs to gcrs
AliyanH May 18, 2023
2cf9a24
update index to use default cs
AliyanH May 18, 2023
e1bfd0c
default layer projection to map's projection when map-meta projection…
AliyanH May 31, 2023
1d6dd65
Add test to ensure a layer without any map-meta gets rendered
AliyanH Jun 2, 2023
64f2404
update _getnativeVariables to support query inputs
AliyanH Jun 14, 2023
330e7d8
Provide map-meta in map-extent shadowRoots to give respect to mapml d…
AliyanH Jun 16, 2023
0f408b7
Add bug fix for empty getFeatureInfo
AliyanH Jun 19, 2023
41f373e
Add map-feature._groupEl._feature property, which will allow code to
Jun 19, 2023
3be3684
Remove cs="gcrs" and <map-meta name="projection" content="OSMTILE">
Jun 19, 2023
5fb03f9
update test to use default projection and CS, remove cs="gcrs", map-m…
AliyanH Jun 20, 2023
376e43a
preserve map-metas in map-extent shadowroot when paginating
AliyanH Jun 25, 2023
f11128f
make statement fail-proof
AliyanH Jun 25, 2023
9585291
Revert Add map-feature._groupEl._feature property. Will integrate (b…
Jun 26, 2023
ca9399d
Add default projection (OSMTILE) + remove use of 'createmap' events
AliyanH Jul 7, 2023
a3b4a0b
Revert "Add default projection (OSMTILE) + remove use of 'createmap' …
AliyanH Jul 18, 2023
b8b529e
fix small bug with remote layer with no map-metas + Add tests
AliyanH Jul 19, 2023
05b6d68
Merge branch 'main' into default-CS-Projection
AliyanH Jul 19, 2023
fafca0e
bug fix after merging upstream
AliyanH Jul 19, 2023
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: 1 addition & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
<map-caption>A pleasing map of Canada</map-caption>
<layer- label="CBMT" src="https://geogratis.gc.ca/mapml/en/cbmtile/cbmt/" checked></layer->
<layer- label="Hat Guy" checked>
<map-meta name="projection" content="CBMTILE"></map-meta>
<map-feature id="twohats" zoom="15" class="twohats">
<map-properties>
<table>
Expand Down Expand Up @@ -117,7 +116,7 @@
</tr>
</table>
</map-properties>
<map-geometry cs="gcrs">
<map-geometry>
<map-point>
<map-coordinates>-75.705278 45.397778</map-coordinates>
</map-point>
Expand Down
4 changes: 2 additions & 2 deletions src/map-feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export class MapFeature extends HTMLElement {
if (this._extentEl.querySelector('map-link[rel=query]')) {
// for query, fallback zoom is the current map zoom level that the query is returned
nativeZoom = this._map.getZoom();
nativeCS = 'pcrs';
nativeCS = 'gcrs';
} else if (this._extentEl.querySelector('map-link[rel=features]')) {
// for templated feature, read fallback from the fetched mapml's map-meta[name=zoom / cs]
nativeZoom = this._extentEl._nativeZoom;
Expand Down Expand Up @@ -340,7 +340,7 @@ export class MapFeature extends HTMLElement {
csLength = csMeta?.length;
nativeCS = csLength
? csMeta[csLength - 1].getAttribute('content')
: 'pcrs';
: 'gcrs';
return { zoom: nativeZoom, cs: nativeCS };
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/mapml/layers/FeatureLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export var FeatureLayer = L.FeatureGroup.extend({
M._metaContentToObject(
mapml.querySelector('map-meta[name=cs]').getAttribute('content')
).content) ||
'PCRS';
'GCRS';
return { zoom: nativeZoom, cs: nativeCS };
},

Expand Down
19 changes: 17 additions & 2 deletions src/mapml/layers/MapMLLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,15 @@ export var MapMLLayer = L.Layer.extend({
projectionMatch =
projection && projection === layer.options.mapprojection;
}
} else {
// default projection set to parent projection when no map-meta projection element present
projection = layer.options.mapprojection;
projectionMatch = true;
serverMeta = projection;
console.log(
`A projection was not assigned to the '${this._layerEl.label}' Layer. Please specify a projection for that layer using a map-meta element. See more here - https://maps4html.org/web-map-doc/docs/elements/meta/`
);
// TODO: Add a more obvious warning.
}

var metaExtent = mapml.querySelector('map-meta[name=extent]'),
Expand Down Expand Up @@ -1496,7 +1505,13 @@ export var MapMLLayer = L.Layer.extend({
}
}
} else {
layer._extent = serverMeta;
if (typeof serverMeta === 'string') {
// when map-meta projection not present for layer
layer._extent = { serverMeta };
} else {
// when map-meta projection present for layer
layer._extent = serverMeta;
}
}
layer._parseLicenseAndLegend(mapml, layer, projection);

Expand Down Expand Up @@ -1728,7 +1743,7 @@ export var MapMLLayer = L.Layer.extend({
let extent = this._extent._mapExtents
? this._extent._mapExtents[0]
: this._extent; // the projections for each extent eould be the same (as) validated in _validProjection, so can use mapExtents[0]
if (!extent) return FALLBACK_PROJECTION;
if (extent.serverMeta) return extent.serverMeta;
switch (extent.tagName.toUpperCase()) {
case 'MAP-EXTENT':
if (extent.hasAttribute('units'))
Expand Down
2 changes: 1 addition & 1 deletion src/mapml/layers/TemplatedFeaturesLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export var TemplatedFeaturesLayer = L.Layer.extend({
.querySelector('map-meta[name=cs]')
.getAttribute('content')
).content) ||
'PCRS');
'GCRS');
features.addData(mapml, nativeCS, nativeZoom);
// "migrate" to extent's shadow
// make a clone, prevent the elements from being removed from mapml file
Expand Down
9 changes: 9 additions & 0 deletions test/e2e/core/metaDefault.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@
tref="http://wms.ess-ws.nrcan.gc.ca/wms/toporama_en?SERVICE=WMS&REQUEST=GetMap&FORMAT=image/jpeg&TRANSPARENT=FALSE&STYLES=&VERSION=1.3.0&LAYERS=WMS-Toporama&WIDTH={w}&HEIGHT={h}&CRS=EPSG:3978&BBOX={xmin},{ymin},{xmax},{ymax}&m4h=t" ></map-link>
</map-extent>
</layer->
<layer- label="Default meta" checked>
<map-feature>
<map-geometry>
<map-point>
<map-coordinates>-79.477626 43.764814</map-coordinates>
</map-point>
</map-geometry>
</map-feature>
</layer->
</mapml-viewer>

</body>
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/core/metaDefault.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,8 @@ test.describe('Playwright Missing Min Max Attribute, Meta Default Tests', () =>
expectedGCRSSecondLayer.bottomRight
);
});
test("Layer with no map-meta's is rendered on map", async () => {
let vector = await page.locator('.mapml-vector-container > svg');
await expect(vector).toHaveCount(1);
});
});
2 changes: 1 addition & 1 deletion test/e2e/mapml-viewer/customTCRS.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ test.describe('Playwright Custom TCRS Tests', () => {

expect(featureThree).toEqual('M382 -28L809 -28L809 399L382 399z');
expect(featureFour).toEqual(
'M55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231z'
'M150 429L171 426L175 438L181 457L183 461L185 463L185 465L187 465L185 468L185 470L184 472L186 477L186 481L188 485L182 486L154 490L154 492L157 494L157 497L158 498L156 501L154 501L151 499L150 495L149 495L148 498L148 501L144 501L141 477L141 448L141 431L139 430L150 429z'
);

expect(staticFeatures).toEqual(false);
Expand Down