1+ import { Util } from './mapml/utils/Util' ;
2+
13export class MapFeature extends HTMLElement {
24 static get observedAttributes ( ) {
35 return [ 'zoom' , 'min' , 'max' ] ;
@@ -10,7 +12,8 @@ export class MapFeature extends HTMLElement {
1012 // for templated or queried features ** native zoom is only used for zoomTo() **
1113 let meta = { } ,
1214 metaEl = this . getMeta ( 'zoom' ) ;
13- if ( metaEl ) meta = M . _metaContentToObject ( metaEl . getAttribute ( 'content' ) ) ;
15+ if ( metaEl )
16+ meta = Util . _metaContentToObject ( metaEl . getAttribute ( 'content' ) ) ;
1417 if ( this . _parentEl . nodeName === 'MAP-LINK' ) {
1518 // nativeZoom = zoom attribute || (sd.map-meta zoom 'value' || 'max') || this._initialZoom
1619 return + ( this . hasAttribute ( 'zoom' )
@@ -43,7 +46,8 @@ export class MapFeature extends HTMLElement {
4346 // for templated or queried features ** native zoom is only used for zoomTo() **
4447 let meta = { } ,
4548 metaEl = this . getMeta ( 'zoom' ) ;
46- if ( metaEl ) meta = M . _metaContentToObject ( metaEl . getAttribute ( 'content' ) ) ;
49+ if ( metaEl )
50+ meta = Util . _metaContentToObject ( metaEl . getAttribute ( 'content' ) ) ;
4751 let projectionMinZoom = 0 ;
4852 if ( this . _parentEl . nodeName === 'MAP-LINK' ) {
4953 // minZoom = min attribute || sd.map-meta min zoom || map-link minZoom
@@ -82,7 +86,8 @@ export class MapFeature extends HTMLElement {
8286 // for templated or queried features ** native zoom is only used for zoomTo() **
8387 let meta = { } ,
8488 metaEl = this . getMeta ( 'zoom' ) ;
85- if ( metaEl ) meta = M . _metaContentToObject ( metaEl . getAttribute ( 'content' ) ) ;
89+ if ( metaEl )
90+ meta = Util . _metaContentToObject ( metaEl . getAttribute ( 'content' ) ) ;
8691 let projectionMaxZoom =
8792 this . getMapEl ( ) . _map . options . crs . options . resolutions . length - 1 ;
8893 if ( this . _parentEl . nodeName === 'MAP-LINK' ) {
@@ -129,10 +134,10 @@ export class MapFeature extends HTMLElement {
129134 }
130135 }
131136 getMapEl ( ) {
132- return M . getClosest ( this , 'mapml-viewer,map[is=web-map]' ) ;
137+ return Util . getClosest ( this , 'mapml-viewer,map[is=web-map]' ) ;
133138 }
134139 getLayerEl ( ) {
135- return M . getClosest ( this , 'layer-' ) ;
140+ return Util . getClosest ( this , 'layer-' ) ;
136141 }
137142
138143 attributeChangedCallback ( name , oldValue , newValue ) {
@@ -231,7 +236,7 @@ export class MapFeature extends HTMLElement {
231236 // layerToRemoveFrom is the L.LayerGroup or L.FeatureGroup to remove this
232237 // feature from...
233238 layerToRemoveFrom . removeLayer ( this . _geometry ) ;
234- // TODO: MOVE THIS LOGIC TO layerToRemoveFrom.removeLayer(M. Geometry)
239+ // TODO: MOVE THIS LOGIC TO layerToRemoveFrom.removeLayer(Geometry)
235240 // if (layerToRemoveFrom._staticFeature) {
236241 // if (layerToRemoveFrom._features[this.zoom]) {
237242 // this._removeInFeatureList(this.zoom);
@@ -302,7 +307,7 @@ export class MapFeature extends HTMLElement {
302307 // the fallback 'gcrs' SHOULD be specified by the MapML spec
303308 // per https://github.com/Maps4HTML/MapML/issues/257
304309 return csMeta
305- ? M . _metaContentToObject ( csMeta . getAttribute ( 'content' ) ) . content
310+ ? Util . _metaContentToObject ( csMeta . getAttribute ( 'content' ) ) . content
306311 : 'gcrs' ;
307312 }
308313
@@ -341,7 +346,7 @@ export class MapFeature extends HTMLElement {
341346 }
342347 let topLeft = L . point ( bboxExtent [ 0 ] , bboxExtent [ 1 ] ) ;
343348 let bottomRight = L . point ( bboxExtent [ 2 ] , bboxExtent [ 3 ] ) ;
344- let pcrsBound = M . boundsToPCRSBounds (
349+ let pcrsBound = Util . boundsToPCRSBounds (
345350 L . bounds ( topLeft , bottomRight ) ,
346351 zoom ,
347352 map . options . projection ,
@@ -360,14 +365,14 @@ export class MapFeature extends HTMLElement {
360365 pcrsBound . min ,
361366 M [ projection ] . scale ( + this . zoom || maxZoom )
362367 ) ;
363- pcrsBound = M . pixelToPCRSBounds (
368+ pcrsBound = Util . pixelToPCRSBounds (
364369 L . bounds ( pixel . subtract ( tileCenter ) , pixel . add ( tileCenter ) ) ,
365370 this . zoom || maxZoom ,
366371 projection
367372 ) ;
368373 }
369374 let result = Object . assign (
370- M . _convertAndFormatPCRS (
375+ Util . _convertAndFormatPCRS (
371376 pcrsBound ,
372377 map . options . crs ,
373378 map . options . projection
@@ -389,14 +394,14 @@ export class MapFeature extends HTMLElement {
389394 . split ( / [ < > \ ] / g) ;
390395 switch ( shape . tagName . toUpperCase ( ) ) {
391396 case 'MAP-POINT' :
392- bboxExtent = M . _updateExtent ( bboxExtent , + data [ 0 ] , + data [ 1 ] ) ;
397+ bboxExtent = Util . _updateExtent ( bboxExtent , + data [ 0 ] , + data [ 1 ] ) ;
393398 break ;
394399 case 'MAP-LINESTRING' :
395400 case 'MAP-POLYGON' :
396401 case 'MAP-MULTIPOINT' :
397402 case 'MAP-MULTILINESTRING' :
398403 for ( let i = 0 ; i < data . length ; i += 2 ) {
399- bboxExtent = M . _updateExtent ( bboxExtent , + data [ i ] , + data [ i + 1 ] ) ;
404+ bboxExtent = Util . _updateExtent ( bboxExtent , + data [ i ] , + data [ i + 1 ] ) ;
400405 }
401406 break ;
402407 default :
@@ -433,7 +438,7 @@ export class MapFeature extends HTMLElement {
433438 newZoom = this . zoom ;
434439 } else {
435440 // if not, calculate the maximum zoom level that can show the feature completely
436- newZoom = M . getMaxZoom ( bound , this . getMapEl ( ) . _map , minZoom , maxZoom ) ;
441+ newZoom = Util . getMaxZoom ( bound , this . getMapEl ( ) . _map , minZoom , maxZoom ) ;
437442 if ( this . max < newZoom ) {
438443 // if the calculated zoom is greater than the value of max zoom attribute, go with max zoom attribute
439444 newZoom = this . max ;
@@ -495,7 +500,7 @@ export class MapFeature extends HTMLElement {
495500 } else if ( el . querySelector ( 'table' ) ) {
496501 // setting properties when table presented
497502 let table = el . querySelector ( 'table' ) . cloneNode ( true ) ;
498- json . properties = M . _table2properties ( table ) ;
503+ json . properties = Util . _table2properties ( table ) ;
499504 } else {
500505 // when no table present, strip any possible html tags to only get text
501506 json . properties = {
@@ -530,11 +535,11 @@ export class MapFeature extends HTMLElement {
530535 json . geometry . geometries = [ ] ;
531536 for ( let shape of shapes ) {
532537 json . geometry . geometries . push (
533- M . _geometry2geojson ( shape , source , dest , options . transform )
538+ Util . _geometry2geojson ( shape , source , dest , options . transform )
534539 ) ;
535540 }
536541 } else {
537- json . geometry = M . _geometry2geojson (
542+ json . geometry = Util . _geometry2geojson (
538543 shapes [ 0 ] ,
539544 source ,
540545 dest ,
0 commit comments