@@ -88,14 +88,26 @@ export var FeatureLayer = L.FeatureGroup.extend({
8888 showPaginationFeature : function ( e ) {
8989 if ( this . options . query && this . _mapmlFeatures [ e . i ] ) {
9090 let feature = this . _mapmlFeatures [ e . i ] ;
91- // remove the prev / next one <map-feature> from shadow if there is any
92- feature . _extentEl . shadowRoot . firstChild ?. remove ( ) ;
91+ if ( e . type === 'featurepagination' ) {
92+ // remove map-feature only (keep meta's) when paginating
93+ feature . _extentEl . shadowRoot . querySelector ( 'map-feature' ) ?. remove ( ) ;
94+ } else {
95+ // empty the map-extent shadowRoot
96+ // remove the prev / next one <map-feature> and <map-meta>'s from shadow if there is any
97+ feature . _extentEl . shadowRoot . replaceChildren ( ) ;
98+ }
9399 this . clearLayers ( ) ;
94100 feature . _featureGroup = this . addData (
95101 feature ,
96102 this . options . nativeCS ,
97103 this . options . nativeZoom
98104 ) ;
105+ // append all map-meta from mapml document
106+ if ( e . meta ) {
107+ for ( let i = 0 ; i < e . meta . length ; i ++ ) {
108+ feature . _extentEl . shadowRoot . appendChild ( e . meta [ i ] ) ;
109+ }
110+ }
99111 feature . _extentEl . shadowRoot . appendChild ( feature ) ;
100112 e . popup . _navigationBar . querySelector ( 'p' ) . innerText =
101113 e . i + 1 + '/' + this . options . _leafletLayer . _totalFeatureCount ;
@@ -116,21 +128,51 @@ export var FeatureLayer = L.FeatureGroup.extend({
116128 }
117129 } ,
118130
131+ // _getNativeVariables: returns an object with the native zoom and CS,
132+ // based on the map-metas that are available within
133+ // the layer or the fallback default values.
134+ // _getNativeVariables: mapml-||layer-||null||[map-feature,...] -> {zoom: _, val: _}
135+ // mapml can be a mapml- element, layer- element, null, or an array of map-features
119136 _getNativeVariables : function ( mapml ) {
120- let nativeZoom =
121- ( mapml . querySelector &&
122- mapml . querySelector ( 'map-meta[name=zoom]' ) &&
123- + M . _metaContentToObject (
124- mapml . querySelector ( 'map-meta[name=zoom]' ) . getAttribute ( 'content' )
125- ) . value ) ||
126- 0 ;
127- let nativeCS =
128- ( mapml . querySelector &&
129- mapml . querySelector ( 'map-meta[name=cs]' ) &&
130- M . _metaContentToObject (
131- mapml . querySelector ( 'map-meta[name=cs]' ) . getAttribute ( 'content' )
132- ) . content ) ||
133- 'PCRS' ;
137+ let nativeZoom , nativeCS ;
138+ // when mapml is an array of features provided by the query
139+ if (
140+ mapml . length &&
141+ mapml [ 0 ] . parentElement . parentElement &&
142+ mapml [ 0 ] . parentElement . parentElement . tagName === 'mapml-'
143+ ) {
144+ let mapmlEl = mapml [ 0 ] . parentElement . parentElement ;
145+ nativeZoom =
146+ ( mapmlEl . querySelector &&
147+ mapmlEl . querySelector ( 'map-meta[name=zoom]' ) &&
148+ + M . _metaContentToObject (
149+ mapmlEl . querySelector ( 'map-meta[name=zoom]' ) . getAttribute ( 'content' )
150+ ) . value ) ||
151+ 0 ;
152+ nativeCS =
153+ ( mapmlEl . querySelector &&
154+ mapmlEl . querySelector ( 'map-meta[name=cs]' ) &&
155+ M . _metaContentToObject (
156+ mapmlEl . querySelector ( 'map-meta[name=cs]' ) . getAttribute ( 'content' )
157+ ) . content ) ||
158+ 'GCRS' ;
159+ } else {
160+ // when mapml is null or a layer-/mapml- element
161+ nativeZoom =
162+ ( mapml . querySelector &&
163+ mapml . querySelector ( 'map-meta[name=zoom]' ) &&
164+ + M . _metaContentToObject (
165+ mapml . querySelector ( 'map-meta[name=zoom]' ) . getAttribute ( 'content' )
166+ ) . value ) ||
167+ 0 ;
168+ nativeCS =
169+ ( mapml . querySelector &&
170+ mapml . querySelector ( 'map-meta[name=cs]' ) &&
171+ M . _metaContentToObject (
172+ mapml . querySelector ( 'map-meta[name=cs]' ) . getAttribute ( 'content' )
173+ ) . content ) ||
174+ 'GCRS' ;
175+ }
134176 return { zoom : nativeZoom , cs : nativeCS } ;
135177 } ,
136178
0 commit comments