* fitEntities * Adjust the map to fit to see the given entity or entities * @param entities Entity or Array of entities to fit in the map view * @param duration? Duration of the transition in milliseconds, defaults to 0ms (asap) * @return this
(entities, duration = 0)
| 700 | * @return this |
| 701 | */ |
| 702 | fitEntities(entities, duration = 0) { |
| 703 | let extent; |
| 704 | |
| 705 | const editor = this.context.systems.editor; |
| 706 | const graph = editor.staging.graph; |
| 707 | |
| 708 | if (Array.isArray(entities)) { |
| 709 | extent = utilTotalExtent(entities, graph); |
| 710 | } else { |
| 711 | extent = entities.extent(graph); |
| 712 | } |
| 713 | if (!isFinite(extent.area())) return this; |
| 714 | |
| 715 | const z2 = numClamp(this.trimmedExtentZoom(extent), 0, 20); |
| 716 | return this.setMapParams(extent.center(), z2, undefined, duration); |
| 717 | } |
| 718 | |
| 719 | |
| 720 | /** |
no test coverage detected