@@ -206,12 +206,12 @@ <h5 class="modal-title" id="tag-example-title"></h5>
206206
207207 < div class ="row-fluid ">
208208 < p id ="shortdesc "> Using WebGL to filter large quantities of features</ p >
209- < div id ="docs "> < p > This example shows how to use < code > ol/layer/WebGLPoints </ code > with a literal style to dynamically filter a large amount
209+ < div id ="docs "> < p > This example shows how to use < code > ol/layer/WebGLVector </ code > with a literal style to dynamically filter a large amount
210210 of point geometries. The above map is based on a dataset from the NASA containing 45k recorded meteorite
211211 landing sites. Each meteorite is marked by a circle on the map (the bigger the circle, the heavier
212212 the object). A pulse effect has been added, which is slightly offset by the year of the impact.</ p >
213213< p > Adjusting the sliders causes the objects outside of the date range to be filtered out of the map. This is done
214- by mutating the variables in the < code > style</ code > object provided to the WebGL layer. Also note that the last snippet
214+ by mutating the variables used by the < code > style</ code > object provided to the WebGL layer. Also note that the last snippet
215215 of code is necessary to make sure the map refreshes itself every frame.</ p >
216216</ div >
217217 </ div >
@@ -223,7 +223,7 @@ <h5 class="source-heading">main.js</h5>
223223import View from 'ol/View.js';
224224import Point from 'ol/geom/Point.js';
225225import TileLayer from 'ol/layer/Tile.js';
226- import WebGLPointsLayer from 'ol/layer/WebGLPoints .js';
226+ import WebGLVectorLayer from 'ol/layer/WebGLVector .js';
227227import {fromLonLat} from 'ol/proj.js';
228228import StadiaMaps from 'ol/source/StadiaMaps.js';
229229import Vector from 'ol/source/Vector.js';
@@ -271,17 +271,6 @@ <h5 class="source-heading">main.js</h5>
271271 'circle-opacity': ['-', 1.0, ['*', animRatio, 0.75]],
272272};
273273
274- const pointsLayer = new WebGLPointsLayer({
275- variables: {
276- minYear: 1850,
277- maxYear: 2015,
278- },
279- style,
280- filter: ['between', ['get', 'year'], ['var', 'minYear'], ['var', 'maxYear']],
281- source: vectorSource,
282- disableHitDetection: true,
283- });
284-
285274// handle input values & events
286275const minYearInput = document.getElementById('min-year');
287276const maxYearInput = document.getElementById('max-year');
@@ -292,12 +281,30 @@ <h5 class="source-heading">main.js</h5>
292281 div.querySelector('span.max-year').textContent = maxYearInput.value;
293282}
294283
284+ const pointsLayer = new WebGLVectorLayer({
285+ variables: {
286+ minYear: parseInt(minYearInput.value),
287+ maxYear: parseInt(maxYearInput.value),
288+ },
289+ style: {
290+ style,
291+ filter: [
292+ 'between',
293+ ['get', 'year'],
294+ ['var', 'minYear'],
295+ ['var', 'maxYear'],
296+ ],
297+ },
298+ source: vectorSource,
299+ disableHitDetection: true,
300+ });
301+
295302minYearInput.addEventListener('input', function () {
296303 pointsLayer.updateStyleVariables({minYear: parseInt(minYearInput.value)});
297304 updateStatusText();
298305});
299306maxYearInput.addEventListener('input', function () {
300- pointsLayer.updateStyleVariables({maxYear: parseInt(minYearInput .value)});
307+ pointsLayer.updateStyleVariables({maxYear: parseInt(maxYearInput .value)});
301308 updateStatusText();
302309});
303310updateStatusText();
0 commit comments