Skip to content

Commit b0a7a7f

Browse files
committed
[AUTO] Sync MapML Build
1 parent 8f980ab commit b0a7a7f

File tree

5 files changed

+33
-101
lines changed

5 files changed

+33
-101
lines changed

dist/index.html

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -52,36 +52,10 @@
5252
}
5353
</style>
5454
</noscript>
55-
<script type="module">
56-
let customProjectionDefinition = `{
57-
"projection": "ATLAS_POLAR_MAP",
58-
"proj4string" : "+proj=aeqd +lat_0=90 +lon_0=-90 +x_0=0 +y_0=0 +ellps=sphere +units=m +no_defs +type=crs",
59-
"code" : "ATLAS_POLAR_MAP",
60-
"origin" : [-20015200,20015200],
61-
"resolutions" : [33073,16536.5,8268.246,4134.123,2067.061,1033.531,516.765],
62-
"bounds" : [[4979939,-4846977],[-5139071,3980038]],
63-
"tilesize" : 256
64-
}`;
65-
let map = document.querySelector("mapml-viewer");
66-
let cProjection = map.defineCustomProjection(customProjectionDefinition);
67-
</script>
68-
<script type="module">
69-
let customProjectionDefinition = `{
70-
"projection": "EPSG3573",
71-
"proj4string" : "+proj=laea +lat_0=90 +lon_0=-100 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs",
72-
"origin" : [-4889334.802955,4889334.802955],
73-
"resolutions" : [38197.92815,19098.96407,9549.482037,4774.741019,2387.370509,1193.685255,596.8426273,298.4213137,149.2106568,74.60532841,37.30266421],
74-
"bounds" : [[-4594983,4507258],[4655569,-4562485]],
75-
"tilesize" : 256
76-
}`;
77-
let map = document.querySelector("mapml-viewer");
78-
let cProjection = map.defineCustomProjection(customProjectionDefinition);
79-
</script>
8055
</head>
8156
<body>
8257
<mapml-viewer projection="CBMTILE" zoom="2" lat="45" lon="-90" controls>
8358
<layer- label="CBMT" src="https://geogratis.gc.ca/mapml/en/cbmtile/cbmt/" checked></layer->
84-
<layer- label="Links Testing" src="demo/canada.mapml" checked></layer->
8559
</mapml-viewer>
8660
</body>
8761
</html>

dist/mapml-viewer.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -675,28 +675,6 @@ export class MapViewer extends HTMLElement {
675675
M[t.projection.toUpperCase()] = M[t.projection]; //adds the projection uppercase to global M
676676
return t.projection;
677677
}
678-
679-
_ready() {
680-
// when used in a custom element, the leaflet script element is hidden inside
681-
// the import's shadow dom.
682-
// this might not work and may not be necessary in standard custom elements
683-
L.Icon.Default.imagePath = (function () {
684-
var imp = document.querySelector('link[rel="import"][href*="web-map.html"]'),
685-
doc = imp ? imp.import : document,
686-
scripts = doc.getElementsByTagName('script'),
687-
leafletRe = /[\/^]leaflet[\-\._]?([\w\-\._]*)\.js\??/;
688-
689-
var i, len, src, path;
690-
691-
for (i = 0, len = scripts.length; i < len; i++) {
692-
src = scripts[i].src;
693-
if (src.match(leafletRe)) {
694-
path = src.split(leafletRe)[0];
695-
return (path ? path + '/' : '') + 'images';
696-
}
697-
}
698-
}());
699-
}
700678
}
701679
// need to provide options { extends: ... } for custom built-in elements
702680
window.customElements.define('mapml-viewer', MapViewer);

dist/mapml.css

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,6 @@
189189
display: inline;
190190
}
191191

192-
.mapml-control-layers summary::-webkit-details-marker {
193-
margin-right: 5px;
194-
}
195192
.mapml-control-layers summary::marker {
196193
margin-right: 5px;
197194
}
@@ -382,6 +379,12 @@
382379
.leaflet-active:not(:focus) {
383380
outline: unset !important;
384381
}
382+
.leaflet-container:not(:focus-within) .mapml-outline {
383+
outline: 0;
384+
}
385+
.leaflet-container:not(:focus-within) .mapml-crosshair {
386+
visibility: hidden;
387+
}
385388

386389
/* Restore the default UA tap highlight color by overriding the opinionated tap
387390
highlight color inherited from leaflet.css. */

dist/mapml.js

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -899,11 +899,11 @@
899899
min: crs.crs.tilematrix.horizontal.min,
900900
max: crs.crs.tilematrix.horizontal.max(crs.resolutions.length-1)
901901
};
902-
if (!isNaN(Number.parseInt(min,10))) {
903-
col.min = Number.parseInt(min,10);
902+
if (!isNaN(Number.parseFloat(min))) {
903+
col.min = Number.parseFloat(min);
904904
}
905-
if (!isNaN(Number.parseInt(max,10))) {
906-
col.max = Number.parseInt(max,10);
905+
if (!isNaN(Number.parseFloat(max))) {
906+
col.max = Number.parseFloat(max);
907907
}
908908
break;
909909
case("row"):
@@ -912,11 +912,11 @@
912912
min: crs.crs.tilematrix.vertical.min,
913913
max: crs.crs.tilematrix.vertical.max(crs.resolutions.length-1)
914914
};
915-
if (!isNaN(Number.parseInt(min,10))) {
916-
row.min = Number.parseInt(min,10);
915+
if (!isNaN(Number.parseFloat(min))) {
916+
row.min = Number.parseFloat(min);
917917
}
918-
if (!isNaN(Number.parseInt(max,10))) {
919-
row.max = Number.parseInt(max,10);
918+
if (!isNaN(Number.parseFloat(max))) {
919+
row.max = Number.parseFloat(max);
920920
}
921921
break;
922922
case('longitude'):
@@ -965,7 +965,7 @@
965965
break;
966966
// unsuportted axis value
967967
}
968-
} else if (type.toLowerCase() === "zoom") {
968+
} else if (type && type.toLowerCase() === "zoom") {
969969
//<input name="..." type="zoom" value="0" min="0" max="17">
970970
zoom = {
971971
name: name,
@@ -1012,9 +1012,6 @@
10121012
var transformation = this.options.crs.transformation,
10131013
tileSize = this.options.crs.options.crs.tile.bounds.max.x,
10141014
scale = L.bind(this.options.crs.scale, this.options.crs),
1015-
tilematrix2pcrs = function (c,zoom) {
1016-
return transformation.untransform(c.multiplyBy(tileSize),scale(zoom));
1017-
},
10181015
pcrs2tilematrix = function(c,zoom) {
10191016
return transformation.transform(c, scale(zoom)).divideBy(tileSize).floor();
10201017
};
@@ -1037,10 +1034,10 @@
10371034
template.pcrs.northing = '';
10381035
}
10391036

1040-
template.pcrs.bounds = L.bounds(
1041-
tilematrix2pcrs(L.point([col.min,row.min]),zoom.value),
1042-
tilematrix2pcrs(L.point([col.max,row.max]),zoom.value)
1043-
);
1037+
template.pcrs.bounds = M.boundsToPCRSBounds(
1038+
L.bounds(L.point([col.min,row.min]),
1039+
L.point([col.max,row.max])),
1040+
zoom.value, this.options.crs, M.axisToCS("column"));
10441041

10451042
template.tilematrix = {};
10461043
template.tilematrix.col = col;
@@ -1363,7 +1360,6 @@
13631360
// it will append its own container for rendering into
13641361
pane: container,
13651362
opacity: opacity,
1366-
imagePath: this.options.imagePath,
13671363
projection:map.options.projection,
13681364
static: true,
13691365
onEachFeature: function(properties, geometry) {
@@ -1935,7 +1931,6 @@
19351931
// it will append its own container for rendering into
19361932
pane: this._container,
19371933
opacity: this.options.opacity,
1938-
imagePath: M.detectImagePath(this._map.getContainer()),
19391934
projection:map.options.projection,
19401935
// each owned child layer gets a reference to the root layer
19411936
_leafletLayer: this,
@@ -1967,7 +1962,6 @@
19671962
// it will append its own container for rendering into
19681963
pane: this._container,
19691964
opacity: this.options.opacity,
1970-
imagePath: M.detectImagePath(this._map.getContainer()),
19711965
projection:map.options.projection,
19721966
// each owned child layer gets a reference to the root layer
19731967
_leafletLayer: this,
@@ -2016,7 +2010,6 @@
20162010
if (this._templateVars) {
20172011
this._templatedLayer = M.templatedLayer(this._templateVars,
20182012
{ pane: this._container,
2019-
imagePath: M.detectImagePath(this._map.getContainer()),
20202013
_leafletLayer: this,
20212014
crs: this.crs
20222015
}).addTo(map);
@@ -2030,7 +2023,6 @@
20302023
if (this._templateVars) {
20312024
this._templatedLayer = M.templatedLayer(this._templateVars,
20322025
{ pane: this._container,
2033-
imagePath: M.detectImagePath(this._map.getContainer()),
20342026
_leafletLayer: this,
20352027
crs: this.crs
20362028
}).addTo(map);
@@ -3578,7 +3570,6 @@
35783570
// zoom
35793571
projection: map.options.projection,
35803572
_leafletLayer: layer,
3581-
imagePath: M.detectImagePath(map.getContainer()),
35823573
query: true,
35833574
static:true,
35843575
});
@@ -4328,7 +4319,7 @@
43284319
switch(inputs[i].getAttribute("type")){
43294320
case "zoom":
43304321
nMinZoom = +inputs[i].getAttribute("min");
4331-
nMaxZoom = +inputs[i].getAttribute("max");
4322+
nMaxZoom = +(inputs[i].hasAttribute("max") ? inputs[i].getAttribute("max") : nMaxZoom);
43324323
value = +inputs[i].getAttribute("value");
43334324
break;
43344325
case "location":
@@ -4434,19 +4425,20 @@
44344425

44354426
convertPCRSBounds: function(pcrsBounds, zoom, projection, cs){
44364427
if(!pcrsBounds || (!zoom && zoom !== 0) || !Number.isFinite(+zoom) || !projection || !cs) return undefined;
4428+
projection = (typeof projection === "string") ? M[projection] : projection;
44374429
switch (cs.toUpperCase()) {
44384430
case "PCRS":
44394431
return pcrsBounds;
44404432
case "TCRS":
44414433
case "TILEMATRIX":
4442-
let minPixel = this[projection].transformation.transform(pcrsBounds.min, this[projection].scale(+zoom)),
4443-
maxPixel = this[projection].transformation.transform(pcrsBounds.max, this[projection].scale(+zoom));
4434+
let minPixel = projection.transformation.transform(pcrsBounds.min, projection.scale(+zoom)),
4435+
maxPixel = projection.transformation.transform(pcrsBounds.max, projection.scale(+zoom));
44444436
if (cs.toUpperCase() === "TCRS") return L.bounds(minPixel, maxPixel);
4445-
let tileSize = M[projection].options.crs.tile.bounds.max.x;
4437+
let tileSize = projection.options.crs.tile.bounds.max.x;
44464438
return L.bounds(L.point(minPixel.x / tileSize, minPixel.y / tileSize), L.point(maxPixel.x / tileSize,maxPixel.y / tileSize));
44474439
case "GCRS":
4448-
let minGCRS = this[projection].unproject(pcrsBounds.min),
4449-
maxGCRS = this[projection].unproject(pcrsBounds.max);
4440+
let minGCRS = projection.unproject(pcrsBounds.min),
4441+
maxGCRS = projection.unproject(pcrsBounds.max);
44504442
return L.bounds(L.point(minGCRS.lng, minGCRS.lat), L.point(maxGCRS.lng, maxGCRS.lat));
44514443
default:
44524444
return undefined;
@@ -4455,7 +4447,8 @@
44554447

44564448
pointToPCRSPoint: function(point, zoom, projection, cs){
44574449
if(!point || (!zoom && zoom !== 0) || !Number.isFinite(+zoom) || !cs || !projection) return undefined;
4458-
let tileSize = M[projection].options.crs.tile.bounds.max.x;
4450+
projection = (typeof projection === "string") ? M[projection] : projection;
4451+
let tileSize = projection.options.crs.tile.bounds.max.x;
44594452
switch(cs.toUpperCase()){
44604453
case "TILEMATRIX":
44614454
return M.pixelToPCRSPoint(L.point(point.x*tileSize,point.y*tileSize),zoom,projection);
@@ -4464,26 +4457,29 @@
44644457
case "TCRS" :
44654458
return M.pixelToPCRSPoint(point,zoom,projection);
44664459
case "GCRS":
4467-
return this[projection].project(L.latLng(point.y,point.x));
4460+
return projection.project(L.latLng(point.y,point.x));
44684461
default:
44694462
return undefined;
44704463
}
44714464
},
44724465

44734466
pixelToPCRSPoint: function(point, zoom, projection){
44744467
if(!point || (!zoom && zoom !== 0) || !Number.isFinite(+zoom) || !projection) return undefined;
4475-
return this[projection].transformation.untransform(point,this[projection].scale(zoom));
4468+
projection = (typeof projection === "string") ? M[projection] : projection;
4469+
return projection.transformation.untransform(point,projection.scale(zoom));
44764470
},
44774471

44784472
boundsToPCRSBounds: function(bounds, zoom, projection, cs){
44794473
if(!bounds || !bounds.max || !bounds.min || (!zoom && zoom !== 0) || !Number.isFinite(+zoom) || !projection || !cs) return undefined;
4474+
projection = (typeof projection === "string") ? M[projection] : projection;
44804475
return L.bounds(M.pointToPCRSPoint(bounds.min, zoom, projection, cs), M.pointToPCRSPoint(bounds.max, zoom, projection, cs));
44814476
},
44824477

44834478
//L.bounds have fixed point positions, where min is always topleft, max is always bottom right, and the values are always sorted by leaflet
44844479
//important to consider when working with pcrs where the origin is not topleft but rather bottomleft, could lead to confusion
44854480
pixelToPCRSBounds : function(bounds, zoom, projection){
44864481
if(!bounds || !bounds.max || !bounds.min || (!zoom && zoom !== 0) || !Number.isFinite(+zoom) || !projection) return undefined;
4482+
projection = (typeof projection === "string") ? M[projection] : projection;
44874483
return L.bounds(M.pixelToPCRSPoint(bounds.min, zoom, projection), M.pixelToPCRSPoint(bounds.max, zoom, projection));
44884484
},
44894485
//meta content is the content attribute of meta

dist/web-map.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -711,25 +711,6 @@ export class WebMap extends HTMLMapElement {
711711
}
712712

713713
_ready() {
714-
// when used in a custom element, the leaflet script element is hidden inside
715-
// the import's shadow dom.
716-
// this might not work and may not be necessary in standard custom elements
717-
L.Icon.Default.imagePath = (function () {
718-
var imp = document.querySelector('link[rel="import"][href*="web-map.html"]'),
719-
doc = imp ? imp.import : document,
720-
scripts = doc.getElementsByTagName('script'),
721-
leafletRe = /[\/^]leaflet[\-\._]?([\w\-\._]*)\.js\??/;
722-
723-
var i, len, src, path;
724-
725-
for (i = 0, len = scripts.length; i < len; i++) {
726-
src = scripts[i].src;
727-
if (src.match(leafletRe)) {
728-
path = src.split(leafletRe)[0];
729-
return (path ? path + '/' : '') + 'images';
730-
}
731-
}
732-
}());
733714
if (this.hasAttribute('name')) {
734715
var name = this.getAttribute('name');
735716
if (name) {

0 commit comments

Comments
 (0)