()
| 310 | return this.previousElementSibling; |
| 311 | } |
| 312 | _createOrGetFeatureLayer() { |
| 313 | // Wait for parent layer to be ready before proceeding |
| 314 | this._parentEl |
| 315 | .whenReady() |
| 316 | .then(() => { |
| 317 | // Detect parent context and get the appropriate layer container |
| 318 | const isMapLink = this._parentEl.nodeName === 'MAP-LINK'; |
| 319 | const parentLayer = isMapLink |
| 320 | ? this._parentEl._templatedLayer |
| 321 | : this._parentEl._layer; |
| 322 | |
| 323 | if (this.isFirst() && parentLayer) { |
| 324 | const parentElement = this._parentEl; |
| 325 | |
| 326 | let map = parentElement.getMapEl()._map; |
| 327 | |
| 328 | this._featureLayer = new MapFeatureLayer(null, { |
| 329 | // pass the vector layer a renderer of its own, otherwise leaflet |
| 330 | // puts everything into the overlayPane |
| 331 | // with this feature creating its own MapFeatureLayer for each |
| 332 | // sub-sequence of features, it means that there may be > 1 <svg> |
| 333 | // container (one per renderer) in the pane... |
| 334 | renderer: featureRenderer(), |
| 335 | // pass the vector layer the container for the parent into which |
| 336 | // it will append its own container for rendering into |
| 337 | pane: parentLayer.getContainer(), |
| 338 | // the bounds will be static, fixed, constant for the lifetime of a (templated) layer |
| 339 | ...(isMapLink && parentElement.getBounds() |
| 340 | ? { layerBounds: parentElement.getBounds() } |
| 341 | : {}), |
| 342 | ...(isMapLink ? { zoomBounds: this._getZoomBounds() } : {}), |
| 343 | ...(isMapLink ? {} : { _leafletLayer: parentElement._layer }), |
| 344 | zIndex: this.position, |
| 345 | projection: map.options.projection, |
| 346 | mapEl: parentElement.getMapEl(), |
| 347 | onEachFeature: function (properties, geometry) { |
| 348 | if (properties) { |
| 349 | const popupOptions = { |
| 350 | autoClose: false, |
| 351 | autoPan: true, |
| 352 | maxHeight: map.getSize().y * 0.5 - 50, |
| 353 | maxWidth: map.getSize().x * 0.7, |
| 354 | minWidth: 165 |
| 355 | }; |
| 356 | var c = document.createElement('div'); |
| 357 | c.classList.add('mapml-popup-content'); |
| 358 | c.insertAdjacentHTML('afterbegin', properties.innerHTML); |
| 359 | geometry.bindPopup(c, popupOptions); |
| 360 | } |
| 361 | } |
| 362 | }); |
| 363 | // this is used by DebugOverlay testing "multipleExtents.test.js |
| 364 | // but do we really need or want each feature to have the bounds of the |
| 365 | // map link? tbd |
| 366 | extend(this._featureLayer.options, { |
| 367 | _leafletLayer: Object.assign(this._featureLayer, { |
| 368 | _layerEl: this.getLayerEl() |
| 369 | }) |
no test coverage detected