MCPcopy Index your code
hub / github.com/Maps4HTML/MapML.js / _createMap

Method _createMap

src/web-map.js:316–377  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

314 }
315 }
316 _createMap() {
317 if (!this._map) {
318 this._map = map(this._container, {
319 center: new LatLng(this.lat, this.lon),
320 minZoom: 0,
321 maxZoom: M[this.projection].options.resolutions.length - 1,
322 projection: this.projection,
323 query: true,
324 contextMenu: true,
325 announceMovement: M.options.announceMovement,
326 featureIndex: true,
327 mapEl: this,
328 crs: M[this.projection],
329 zoom: this.zoom,
330 zoomControl: false
331 });
332 this._addToHistory();
333
334 this._createControls();
335 this._toggleControls();
336 this._crosshair = crosshair().addTo(this._map);
337
338 if (M.options.featureIndexOverlayOption)
339 this._featureIndexOverlay = featureIndexOverlay().addTo(this._map);
340
341 if (this.hasAttribute('name')) {
342 var name = this.getAttribute('name');
343 if (name) {
344 this.poster = document.querySelector(
345 'img[usemap=' + '"#' + name + '"]'
346 );
347 // firefox has an issue where the attribution control's use of
348 // _container.innerHTML does not work properly if the engine is throwing
349 // exceptions because there are no area element children of the image map
350 // for firefox only, a workaround is to actually remove the image...
351 if (this.poster) {
352 if (Browser.gecko) {
353 this.poster.removeAttribute('usemap');
354 }
355 //this.appendChild(this.poster);
356 }
357 }
358 }
359
360 // undisplay the img in the image map, because it's not needed now.
361 // gives a slight FOUC, unless:
362 // 1) the img is pre-styled (https://github.com/Maps4HTML/MapML.js/blob/80a4a4e372d2ef61bb7cad6a111e17e396b8e908/index-map-area.html#L35)
363 // 2) placed after the map element
364 if (this.poster) {
365 this.poster.setAttribute('hidden', '');
366 }
367
368 // https://github.com/Maps4HTML/MapML.js/issues/274
369 this.setAttribute('role', 'application');
370 // Make the Leaflet container element programmatically identifiable
371 // (https://github.com/Leaflet/Leaflet/issues/7193).
372 this._container.setAttribute('role', 'region');
373 this._container.setAttribute('aria-label', 'Interactive map');

Callers 1

connectedCallbackMethod · 0.95

Calls 8

_addToHistoryMethod · 0.95
_createControlsMethod · 0.95
_toggleControlsMethod · 0.95
_setUpEventsMethod · 0.95
crosshairFunction · 0.90
featureIndexOverlayFunction · 0.90
getAttributeMethod · 0.80
setAttributeMethod · 0.80

Tested by

no test coverage detected