From 3d0f7e4af8508b145a0856305703a38fed1c3475 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Wed, 30 Oct 2019 14:39:54 +0100 Subject: [PATCH] Update the vector-tile-selection example --- examples/vector-tile-selection.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/vector-tile-selection.js b/examples/vector-tile-selection.js index 2e541e965d..b351c08771 100644 --- a/examples/vector-tile-selection.js +++ b/examples/vector-tile-selection.js @@ -7,18 +7,19 @@ import {Fill, Stroke, Style} from '../src/ol/style.js'; // lookup for selection objects let selection = {}; -// feature property to act as identifier -const idProp = 'iso_a3'; const vtLayer = new VectorTileLayer({ declutter: true, source: new VectorTileSource({ - format: new MVT(), + maxZoom: 15, + format: new MVT({ + idProperty: 'iso_a3' + }), url: 'https://ahocevar.com/geoserver/gwc/service/tms/1.0.0/' + 'ne:ne_10m_admin_0_countries@EPSG%3A900913@pbf/{z}/{x}/{-y}.pbf' }), style: function(feature) { - const selected = !!selection[feature.get(idProp)]; + const selected = !!selection[feature.getId()]; return new Style({ stroke: new Stroke({ color: selected ? 'rgba(200,20,20,0.8)' : 'gray', @@ -56,7 +57,7 @@ map.on('click', function(event) { if (!feature) { return; } - const fid = feature.get(idProp); + const fid = feature.getId(); if (selectElement.value === 'singleselect') { selection = {};