Skip to content

Commit 953c00d

Browse files
committed
fix: Support 255,255,255 in pixelmaps as a no-data value
This is marked as a fix rather than a feature as some users were expecting this behavior.
1 parent dec178c commit 953c00d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/pixelmapFeature.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ var util = require('./util');
1010
* @extends geo.feature.spec
1111
* @property {string|function|HTMLImageElement} [url] URL of a pixel map or an
1212
* HTML Image element. The rgb data is interpreted as an index of the form
13-
* 0xbbggrr. The alpha channel is ignored.
13+
* 0xbbggrr. The alpha channel is ignored. An index of 0xffffff is treated
14+
* as a no-data value for hit-tests.
1415
* @property {geo.geoColor|function} [color] The color that should be used
1516
* for each data element. Data elements correspond to the indices in the
1617
* pixel map. If an index is larger than the number of data elements, it will

src/webgl/pixelmapFeature.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ var webgl_pixelmapFeature = function (arg) {
6363
context.drawImage(img, x, y, 1, 1, 0, 0, 1, 1);
6464
const pixel = context.getImageData(0, 0, 1, 1).data;
6565
const idx = pixel[0] + pixel[1] * 256 + pixel[2] * 256 * 256;
66+
if (idx === 16777215) {
67+
continue;
68+
}
6669
result = {
6770
index: [idx],
6871
found: [m_this.data()[idx]]

0 commit comments

Comments
 (0)