From 44d9c42ad06927c34775a5310f2eb8a511adb77b Mon Sep 17 00:00:00 2001 From: Lucas Wojciechowski Date: Tue, 13 Dec 2016 15:09:22 -0800 Subject: [PATCH] Add data-driven styling support for "icon-offset" (#3791) * Add support for icon-offset property functions * Moved the icon-offset determination to the symbol bucket * Updated package.json to point to new style and test suite * Update package.json * Fix icon-offset zoom-and-property functions * Update package.json --- js/data/bucket/symbol_bucket.js | 3 ++- js/symbol/shaping.js | 6 +++--- package.json | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/js/data/bucket/symbol_bucket.js b/js/data/bucket/symbol_bucket.js index dc2deb947dc..199828f1931 100644 --- a/js/data/bucket/symbol_bucket.js +++ b/js/data/bucket/symbol_bucket.js @@ -295,7 +295,8 @@ class SymbolBucket { let shapedIcon; if (feature.icon) { const image = icons[feature.icon]; - shapedIcon = shapeIcon(image, layout); + const iconOffset = this.layers[0].getLayoutValue('icon-offset', {zoom: this.zoom}, feature.properties); + shapedIcon = shapeIcon(image, iconOffset); if (image) { if (this.sdfIcons === undefined) { diff --git a/js/symbol/shaping.js b/js/symbol/shaping.js index 7f051717cb2..e4f4982e17f 100644 --- a/js/symbol/shaping.js +++ b/js/symbol/shaping.js @@ -234,11 +234,11 @@ function align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLin } } -function shapeIcon(image, layout) { +function shapeIcon(image, iconOffset) { if (!image || !image.rect) return null; - const dx = layout['icon-offset'][0]; - const dy = layout['icon-offset'][1]; + const dx = iconOffset[0]; + const dy = iconOffset[1]; const x1 = dx - image.width / 2; const x2 = x1 + image.width; const y1 = dy - image.height / 2; diff --git a/package.json b/package.json index e137e31431d..484cca19132 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "in-publish": "^2.0.0", "jsdom": "^9.4.2", "lodash.template": "^4.4.0", - "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#8a047e6226b996fa8fc4c61a30aebb55c6234896", + "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#52acb6e9e4b75b7e765ef087a0e539739e9846c1", "minifyify": "^7.0.1", "npm-run-all": "^3.0.0", "nyc": "^8.3.0",