|
277 | 277 | // must have leaflet-pane class because of new/changed rule in leaflet.css |
278 | 278 | // info: https://github.com/Leaflet/Leaflet/pull/4597 |
279 | 279 | L.DomUtil.addClass(this._container,'leaflet-pane mapml-vector-container'); |
| 280 | + |
| 281 | + let anim = L.DomUtil.create("style", "mapml-feature-animation", this._container); |
| 282 | + anim.innerHTML = `@keyframes pathSelect { |
| 283 | + 0% {stroke: white;} |
| 284 | + 50% {stroke: black;} |
| 285 | + } |
| 286 | + |
| 287 | + .mapml-path-selected { |
| 288 | + animation-name: pathSelect; |
| 289 | + animation-duration: 1s; |
| 290 | + stroke-width: 5; |
| 291 | + stroke: black; |
| 292 | + }`; |
| 293 | + |
280 | 294 | L.setOptions(this.options.renderer, {pane: this._container}); |
281 | 295 | this._layers = {}; |
282 | 296 | if(this.options.query){ |
|
325 | 339 | if(this._staticFeature){ |
326 | 340 | return { |
327 | 341 | 'moveend':this._handleMoveEnd, |
| 342 | + 'zoomend' : this._handleZoomEnd, |
328 | 343 | }; |
329 | 344 | } |
330 | 345 | return { |
|
341 | 356 | } else { |
342 | 357 | path._path.removeAttribute("tabindex"); |
343 | 358 | } |
344 | | - if(path._path.childElementCount === 0) { |
345 | | - let title = L.SVG.create("title"); |
346 | | - title.innerHTML = path.accessibleTitle; |
347 | | - path._path.appendChild(title); |
348 | | - } |
| 359 | + path._path.setAttribute("aria-label", path.accessibleTitle); |
349 | 360 | path._path.setAttribute("aria-expanded", "false"); |
350 | 361 | /* jshint ignore:start */ |
351 | 362 | L.DomEvent.on(path._path, "keyup keydown", (e)=>{ |
352 | 363 | if((e.keyCode === 9 || e.keyCode === 16 || e.keyCode === 13) && e.type === "keyup"){ |
| 364 | + path._path.classList.add("mapml-path-selected"); |
353 | 365 | path.openTooltip(); |
354 | 366 | } else { |
| 367 | + path._path.classList.remove("mapml-path-selected"); |
355 | 368 | path.closeTooltip(); |
356 | 369 | } |
357 | 370 | }); |
| 371 | + path._path.classList.remove("mapml-path-selected"); |
| 372 | + if(path.isTooltipOpen())path.closeTooltip(); |
358 | 373 | /* jshint ignore:end */ |
359 | 374 | } |
360 | 375 | } |
|
418 | 433 | }, |
419 | 434 |
|
420 | 435 | _handleMoveEnd : function(){ |
| 436 | + let mapZoom = this._map.getZoom(), |
| 437 | + withinZoom = mapZoom <= this.zoomBounds.maxZoom && mapZoom >= this.zoomBounds.minZoom; |
| 438 | + this.isVisible = withinZoom && this._layers && this.layerBounds && |
| 439 | + this.layerBounds.overlaps( |
| 440 | + M.pixelToPCRSBounds( |
| 441 | + this._map.getPixelBounds(), |
| 442 | + mapZoom,this._map.options.projection)); |
| 443 | + this._removeCSS(); |
| 444 | + this._updateTabIndex(); |
| 445 | + }, |
| 446 | + |
| 447 | + _handleZoomEnd: function(e){ |
421 | 448 | let mapZoom = this._map.getZoom(); |
422 | 449 | if(mapZoom > this.zoomBounds.maxZoom || mapZoom < this.zoomBounds.minZoom){ |
423 | 450 | this.clearLayers(); |
424 | | - this.isVisible = false; |
425 | 451 | return; |
426 | 452 | } |
427 | 453 | let clampZoom = this._clampZoom(mapZoom); |
428 | 454 | this._resetFeatures(clampZoom); |
429 | | - this.isVisible = this._layers && this.layerBounds && |
430 | | - this.layerBounds.overlaps( |
431 | | - M.pixelToPCRSBounds( |
432 | | - this._map.getPixelBounds(), |
433 | | - mapZoom,this._map.options.projection)); |
434 | | - this._removeCSS(); |
435 | | - this._updateTabIndex(); |
436 | 455 | }, |
437 | 456 |
|
438 | 457 | //sets default if any are missing, better to only replace ones that are missing |
|
627 | 646 | _removeCSS: function(){ |
628 | 647 | let toDelete = this._container.querySelectorAll("link[rel=stylesheet],style"); |
629 | 648 | for(let i = 0; i < toDelete.length;i++){ |
| 649 | + if(toDelete[i].classList.contains("mapml-feature-animation")) continue; |
630 | 650 | this._container.removeChild(toDelete[i]); |
631 | 651 | } |
632 | 652 | }, |
|
2365 | 2385 | var c = document.createElement('div'); |
2366 | 2386 | c.classList.add("mapml-popup-content"); |
2367 | 2387 | c.insertAdjacentHTML('afterbegin', properties.innerHTML); |
2368 | | - geometry.bindPopup(c, {autoPan:false, minWidth: 108}); |
| 2388 | + geometry.bindPopup(c, {autoClose: false, minWidth: 108}); |
2369 | 2389 | } |
2370 | 2390 | } |
2371 | 2391 | }); |
|
2395 | 2415 | var c = document.createElement('div'); |
2396 | 2416 | c.classList.add("mapml-popup-content"); |
2397 | 2417 | c.insertAdjacentHTML('afterbegin', properties.innerHTML); |
2398 | | - geometry.bindPopup(c, {autoPan:false, minWidth: 108}); |
| 2418 | + geometry.bindPopup(c, {autoClose: false, minWidth: 108}); |
2399 | 2419 | } |
2400 | 2420 | } |
2401 | 2421 | }).addTo(map); |
|
3875 | 3895 | crs = layer.crs, |
3876 | 3896 | tileSize = map.options.crs.options.crs.tile.bounds.max.x, |
3877 | 3897 | container = layer._container, |
3878 | | - popupOptions = {autoPan: true, maxHeight: (map.getSize().y * 0.5) - 50}, |
| 3898 | + popupOptions = {autoClose: false, autoPan: true, maxHeight: (map.getSize().y * 0.5) - 50}, |
3879 | 3899 | tcrs2pcrs = function (c) { |
3880 | 3900 | return crs.transformation.untransform(c,crs.scale(zoom)); |
3881 | 3901 | }, |
|
0 commit comments