Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14971 from ahocevar/flush-declutter
New flushDeclutterItems() map method to control declutter stack
- Loading branch information
Showing
7 changed files
with
162 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.map .ol-rotate { | ||
left: .5em; | ||
bottom: .5em; | ||
top: auto; | ||
right: auto; | ||
} | ||
.map:-webkit-full-screen { | ||
height: 100%; | ||
margin: 0; | ||
} | ||
.map:fullscreen { | ||
height: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
layout: example.html | ||
title: Declutter Group | ||
shortdesc: Declutter vector layers by groups | ||
docs: > | ||
This shows how to specify when vector(tile) layers are decluttered if `declutter` is set to true. By default, | ||
all decluttering will happen after all layers have been rendered. Calling the map's `flushDeclutter()` method | ||
makes decluttering occur immediately. This is useful for layers that need to be entirely rendered above the declutter items | ||
of layers lower in the layer stack. In the example, the blue square overlay displays above the decluttered vector symbols | ||
and labels. | ||
tags: "mapbox, declutter, vector" | ||
cloak: | ||
- key: get_your_own_D6rA4zTHduk6KOKTXzGB | ||
value: Get your own API key at https://www.maptiler.com/cloud/ | ||
--- | ||
<div id="map" class="map"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import {Feature, Map, View} from '../src/ol/index.js'; | ||
import {Group as LayerGroup, Vector as VectorLayer} from '../src/ol/layer.js'; | ||
import {Vector as VectorSource} from '../src/ol/source.js'; | ||
import {apply} from 'ol-mapbox-style'; | ||
import {fromExtent} from '../src/ol/geom/Polygon.js'; | ||
import {getCenter} from '../src/ol/extent.js'; | ||
|
||
const square = [-12e6, 3.5e6, -10e6, 5.5e6]; | ||
const overlay = new VectorLayer({ | ||
source: new VectorSource({ | ||
features: [new Feature(fromExtent(square))], | ||
}), | ||
style: { | ||
'stroke-color': 'rgba(180, 180, 255, 1)', | ||
'stroke-width': 1, | ||
'fill-color': 'rgba(200, 200, 255, 0.85)', | ||
}, | ||
}); | ||
|
||
const layer = new LayerGroup(); | ||
apply( | ||
layer, | ||
'https://api.maptiler.com/maps/topo-v2/style.json?key=get_your_own_D6rA4zTHduk6KOKTXzGB' | ||
); | ||
|
||
const map = new Map({ | ||
target: 'map', | ||
view: new View({ | ||
center: getCenter(square), | ||
zoom: 4, | ||
}), | ||
layers: [layer, overlay], | ||
}); | ||
|
||
overlay.on('prerender', () => map.flushDeclutterItems()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters