Skip to content

Commit

Permalink
properly apply style changes to the vector layer:
Browse files Browse the repository at this point in the history
  • Loading branch information
prusswan committed Sep 3, 2024
1 parent 08bdb06 commit 39529a7
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions examples/layer/map.layer.gppvtile.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ function applyStyle() {
if (l.paint[c].stops) {
l.paint[c].stops.forEach(function (s) {
if (!(/#ffffff/i.test(s[1]) && /^saturate/.test(operation))) {
s[1] = getChromaColor(chroma(s[1])[operation](opt));
s[1] = getChromaColor(chroma(s[1])[operation](opt));
}
// console.log('STOP:',s)
})
Expand All @@ -245,20 +245,29 @@ function applyStyle() {
try {
if (l.paint[c].stops) {
l.paint[c].stops.forEach(function (s) {
s[1] = getChromaColor(chroma.mix(s[1],color));
s[1] = getChromaColor(chroma.mix(s[1],color));
})
} else {
l.paint[c] = getChromaColor(chroma.mix(l.paint[c],color));
l.paint[c] = getChromaColor(chroma.mix(l.paint[c],color));
}
} catch(e) {};
break;
break;
}
}
}
});
})
}
}

// trigger tile refresh by incrementing style id, see: https://github.com/openlayers/ol-mapbox-style/issues/959
try {
currentStyle["id"] = currentStyle["id"] + 1;
}
catch {
currentStyle["id"] = 0;
}

olms.applyStyle(vlayer, currentStyle, "plan_ign");
}

Expand Down Expand Up @@ -367,7 +376,7 @@ selStyle.push(new ol.style.Style({
return new ol.geom.Point(f.getGeometry().getFirstCoordinate())
}
}))
var select = new ol.layer.Vector({
var select = new ol.layer.Vector({
source: new ol.source.Vector(),
style: selStyle
});
Expand All @@ -383,7 +392,7 @@ map.on('click', function() {
var tooltip = new ol.Overlay.Tooltip({ className: 'default', positioning: 'bottom-center' });
map.addOverlay(tooltip);

var hover = new ol.interaction.Hover({
var hover = new ol.interaction.Hover({
cursor: "pointer",
layers: [vlayer]
});
Expand All @@ -407,7 +416,7 @@ hover.on("enter", function(e) {
}
tooltip.setInfo(info);
//console.log(feature.getProperties());
// Select feature
// Select feature
if (showGeom) {
var coords = [];
if (feature instanceof ol.Feature) {
Expand All @@ -427,7 +436,7 @@ hover.on("enter", function(e) {
coords = coords;
break;
}
case 'MultiLineString' :
case 'MultiLineString' :
case 'Polygon' : {
coords = [coords];
break;
Expand Down

0 comments on commit 39529a7

Please sign in to comment.