MCPcopy Create free account
hub / github.com/Maps4HTML/MapML.js / isVisible

Method isVisible

src/map-link.js:985–1011  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

983 return zoomBounds;
984 }
985 isVisible() {
986 if (this.disabled) return false;
987 let isVisible = false,
988 map = this.getMapEl(),
989 mapZoom = map.zoom,
990 extent = map.extent,
991 xmin = extent.topLeft.pcrs.horizontal,
992 xmax = extent.bottomRight.pcrs.horizontal,
993 ymin = extent.bottomRight.pcrs.vertical,
994 ymax = extent.topLeft.pcrs.vertical,
995 mapBounds = bounds(point(xmin, ymin), point(xmax, ymax));
996
997 if (this._templatedLayer) {
998 isVisible = this._templatedLayer.isVisible();
999 } else if (this.rel === 'query') {
1000 const minZoom = this.extent.zoom.minZoom,
1001 maxZoom = this.extent.zoom.maxZoom,
1002 withinZoomBounds = (z) => {
1003 return minZoom <= z && z <= maxZoom;
1004 };
1005
1006 if (this.getBounds().overlaps(mapBounds) && withinZoomBounds(mapZoom)) {
1007 isVisible = true;
1008 }
1009 }
1010 return isVisible;
1011 }
1012 _createSelfOrStyleLink() {
1013 let layerEl = this.getLayerEl();
1014 const changeStyle = function (e) {

Calls 4

getMapElMethod · 0.95
getBoundsMethod · 0.95
boundsFunction · 0.85
withinZoomBoundsFunction · 0.85

Tested by

no test coverage detected