From 6b1bf537adae8215f1c3e4cf04ce3a908aa91683 Mon Sep 17 00:00:00 2001 From: akacarlyann Date: Sat, 14 Apr 2018 14:44:09 -0700 Subject: [PATCH] Remove duplicate add to data-join tooltip if colorProperty == heightProperty; add note to legend title if two properties used for data-driven styling --- mapboxgl/templates/choropleth.html | 11 ++++++++++- mapboxgl/templates/vector_choropleth.html | 10 ++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/mapboxgl/templates/choropleth.html b/mapboxgl/templates/choropleth.html index be2b605..402a9a0 100644 --- a/mapboxgl/templates/choropleth.html +++ b/mapboxgl/templates/choropleth.html @@ -10,7 +10,16 @@ {% block legend %} var legend = document.getElementById('legend'); - calcCircleColorLegend({{ colorStops }}, "{{ colorProperty }}"); + + {% if colorStops and colorProperty and heightProperty %} + {% if colorProperty != heightProperty %} + calcCircleColorLegend({{ colorStops }}, "{{ colorProperty }} vs. {{ heightProperty }}"); + {% else %} + calcCircleColorLegend({{ colorStops }}, "{{ colorProperty }}"); + {% endif %} + {% else %} + calcCircleColorLegend({{ colorStops }}, "{{ colorProperty }}"); + {% endif %} {% endblock legend %} diff --git a/mapboxgl/templates/vector_choropleth.html b/mapboxgl/templates/vector_choropleth.html index 582b33a..139b913 100644 --- a/mapboxgl/templates/vector_choropleth.html +++ b/mapboxgl/templates/vector_choropleth.html @@ -16,7 +16,9 @@ popUpKeys[row["{{ dataJoinProperty }}"]] = row["{{ colorProperty }}"]; {% if extrudeChoropleth %} - heightPopUpKeys[row["{{ dataJoinProperty }}"]] = row["{{ heightProperty }}"]; + {% if colorProperty != heightProperty %} + heightPopUpKeys[row["{{ dataJoinProperty }}"]] = row["{{ heightProperty }}"]; + {% endif %} {% endif %} layerFilter.push(row["{{ dataJoinProperty }}"]); @@ -136,9 +138,9 @@ popup_html += '
  • ' + "{{ colorProperty }}".toUpperCase() + ': ' + popUpKeys[f.properties["{{ vectorJoinDataProperty }}"]] + '
  • ' {% if extrudeChoropleth %} - - popup_html += '
  • ' + "{{ heightProperty }}".toUpperCase() + ': ' + heightPopUpKeys[f.properties["{{ vectorJoinDataProperty }}"]] + '
  • ' - + {% if colorProperty != heightProperty %} + popup_html += '
  • ' + "{{ heightProperty }}".toUpperCase() + ': ' + heightPopUpKeys[f.properties["{{ vectorJoinDataProperty }}"]] + '
  • ' + {% endif %} {% endif %} popup_html += ''