From 7bdcbc3eee0c504700a812ee7de0b869abe9feee Mon Sep 17 00:00:00 2001 From: Brian Sperlongano Date: Thu, 22 Jun 2023 21:33:33 -0400 Subject: [PATCH 1/2] Refactor place icons --- icons/place_dot.svg | 3 ++ ...{star_state_capital.svg => place_star.svg} | 0 ...n_capital.svg => place_star_in_circle.svg} | 0 src/layer/place.js | 28 +++++++++---------- 4 files changed, 16 insertions(+), 15 deletions(-) create mode 100644 icons/place_dot.svg rename icons/{star_state_capital.svg => place_star.svg} (100%) rename icons/{star_nation_capital.svg => place_star_in_circle.svg} (100%) diff --git a/icons/place_dot.svg b/icons/place_dot.svg new file mode 100644 index 000000000..e4c9b3e14 --- /dev/null +++ b/icons/place_dot.svg @@ -0,0 +1,3 @@ + + + diff --git a/icons/star_state_capital.svg b/icons/place_star.svg similarity index 100% rename from icons/star_state_capital.svg rename to icons/place_star.svg diff --git a/icons/star_nation_capital.svg b/icons/place_star_in_circle.svg similarity index 100% rename from icons/star_nation_capital.svg rename to icons/place_star_in_circle.svg diff --git a/src/layer/place.js b/src/layer/place.js index 5335bbfb2..e95deb15d 100644 --- a/src/layer/place.js +++ b/src/layer/place.js @@ -20,18 +20,6 @@ const cityLabelPaint = { "text-halo-blur": labelHaloBlur, }; -const cityIcon = [ - "match", - ["get", "capital"], - 2, - "star_nation_capital", - 3, - "star_state_capital", - 4, - "star_state_capital", - "dot_city", -]; - export const village = { id: "place_village", type: "symbol", @@ -63,7 +51,7 @@ export const village = { [12, 12], ], }, - "icon-image": cityIcon, + "icon-image": "place_city", "icon-size": { base: 1.0, stops: [ @@ -126,7 +114,7 @@ export const town = { [12, 18], ], }, - "icon-image": cityIcon, + "icon-image": "place_city", "icon-size": { base: 1.2, stops: [ @@ -185,7 +173,17 @@ export const city = { [11, 24], ], }, - "icon-image": cityIcon, + "icon-image": [ + "match", + ["get", "capital"], + 2, + "place_star_in_circle", + 3, + "place_star", + 4, + "place_star", + "place_dot", + ], "icon-size": { base: 1.2, stops: [ From feabf84b0de121d3caf31ed1d768fb11149e4548 Mon Sep 17 00:00:00 2001 From: Brian Sperlongano Date: Mon, 3 Jul 2023 09:45:27 -0400 Subject: [PATCH 2/2] Consolidate city icon styling --- icons/dot_city.svg | 3 --- icons/place_dot.svg | 4 +-- src/layer/place.js | 60 +++++++++++++++++---------------------------- 3 files changed, 25 insertions(+), 42 deletions(-) delete mode 100644 icons/dot_city.svg diff --git a/icons/dot_city.svg b/icons/dot_city.svg deleted file mode 100644 index d6677ac9b..000000000 --- a/icons/dot_city.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/icons/place_dot.svg b/icons/place_dot.svg index e4c9b3e14..d6677ac9b 100644 --- a/icons/place_dot.svg +++ b/icons/place_dot.svg @@ -1,3 +1,3 @@ - - + + diff --git a/src/layer/place.js b/src/layer/place.js index e95deb15d..a034b8d32 100644 --- a/src/layer/place.js +++ b/src/layer/place.js @@ -20,27 +20,29 @@ const cityLabelPaint = { "text-halo-blur": labelHaloBlur, }; +const minorLocationStepFilter = [ + "step", + ["zoom"], + ["<=", ["get", "rank"], 2], + 6, + ["<=", ["get", "rank"], 4], + 7, + ["<=", ["get", "rank"], 5], + 8, + ["<=", ["get", "rank"], 9], + 10, + [">=", ["get", "rank"], 1], +]; + +function filterPlace(type) { + return ["==", ["get", "class"], type]; +} + export const village = { id: "place_village", type: "symbol", paint: cityLabelPaint, - filter: [ - "all", - ["==", ["get", "class"], "village"], - [ - "step", - ["zoom"], - ["<=", ["get", "rank"], 2], - 6, - ["<=", ["get", "rank"], 4], - 7, - ["<=", ["get", "rank"], 5], - 8, - ["<=", ["get", "rank"], 9], - 10, - [">=", ["get", "rank"], 1], - ], - ], + filter: ["all", filterPlace("village"), minorLocationStepFilter], layout: { "text-font": ["Americana-Bold"], "text-size": { @@ -51,7 +53,7 @@ export const village = { [12, 12], ], }, - "icon-image": "place_city", + "icon-image": "place_dot", "icon-size": { base: 1.0, stops: [ @@ -87,23 +89,7 @@ export const town = { id: "place_town", type: "symbol", paint: cityLabelPaint, - filter: [ - "all", - ["==", ["get", "class"], "town"], - [ - "step", - ["zoom"], - ["<=", ["get", "rank"], 2], - 6, - ["<=", ["get", "rank"], 4], - 7, - ["<=", ["get", "rank"], 5], - 8, - ["<=", ["get", "rank"], 9], - 10, - [">=", ["get", "rank"], 1], - ], - ], + filter: ["all", filterPlace("town"), minorLocationStepFilter], layout: { "text-font": ["Americana-Bold"], "text-size": { @@ -114,7 +100,7 @@ export const town = { [12, 18], ], }, - "icon-image": "place_city", + "icon-image": "place_dot", "icon-size": { base: 1.2, stops: [ @@ -152,7 +138,7 @@ export const city = { paint: cityLabelPaint, filter: [ "all", - ["==", ["get", "class"], "city"], + filterPlace("city"), [ "step", ["zoom"],