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

Method zoomTo

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

Source from the content-addressed store, hash-verified

151 : null;
152 }
153 zoomTo() {
154 let extent = this.extent;
155 if (!extent) return;
156 let map = this.getMapEl()._map,
157 xmin = extent.topLeft.pcrs.horizontal,
158 xmax = extent.bottomRight.pcrs.horizontal,
159 ymin = extent.bottomRight.pcrs.vertical,
160 ymax = extent.topLeft.pcrs.vertical,
161 newBounds = bounds(point(xmin, ymin), point(xmax, ymax)),
162 center = map.options.crs.unproject(newBounds.getCenter(true)),
163 maxZoom = extent.zoom.maxZoom,
164 minZoom = extent.zoom.minZoom;
165 map.setView(center, Util.getMaxZoom(newBounds, map, minZoom, maxZoom), {
166 animate: false
167 });
168 }
169 getMapEl() {
170 return Util.getClosest(this, 'mapml-viewer,map[is=web-map]');
171 }

Callers

nothing calls this directly

Calls 2

getMapElMethod · 0.95
boundsFunction · 0.85

Tested by

no test coverage detected