Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geomap: adding option to merge legend label and symbol #9752

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions site/pages/docs/ref/geomap/geomap-en.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ $document.on( "wb-ready.wb-geomap", "#sample_map", function( event, map ) {
<td><code>static</code></td>
<td>If present, the widgets (pan, zoom, select, etc.) will not be added to the map. This is useful for scenarios where a simple map with one or more features is required to communicate some value or idea (e.g. an extent map for a data product).</td>
</tr>
<tr>
<td><code>legend-label-only</code></td>
<td>If present and if there is only one legend item within a certain layer, the symbol description will be hidden (as it can be the same as the label). In which case, the title of the layer must represent the legend item.</td>
</tr>
</tbody>
</table>
<p><strong>Configuration class example:</strong></p>
Expand Down
4 changes: 4 additions & 0 deletions site/pages/docs/ref/geomap/geomap-fr.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ $document.on( "wb-ready.wb-geomap", "#sample_map", function( event, map ) {
<td><code>static</code></td>
<td>If present, the widgets (pan, zoom, select, etc.) will not be added to the map. This is useful for scenarios where a simple map with one or more features is required to communicate some value or idea (e.g. an extent map for a data product).</td>
</tr>
<tr>
<td><code>legend-label-only</code></td>
<td>If present and if there is only one legend item within a certain layer, the symbol description will be hidden (as it can be the same as the label). In which case, the title of the layer must represent the legend item.</td>
</tr>
</tbody>
</table>
<p><strong>Configuration class example:</strong></p>
Expand Down
9 changes: 8 additions & 1 deletion src/plugins/deps/geomap-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -3546,7 +3546,14 @@ MapLegend.prototype.symbolize = function( mapLayer ) {
}

// append the list to the legend
$( "#sb_" + layerName ).html( "<ul class='list-unstyled'>" + symbolList + "</ul>" );
if ( $( "#sb_" + layerName ).closest( ".wb-geomap" ).hasClass( "legend-label-only" ) && symbolList.match( /<li>/g ) && symbolList.match( /<li>/g ).length === 1 ) {

// role="presentation" added here because there is only one item and the icon is now only there for styling purposes
$( "#sb_" + layerName ).html( "<ul class='list-unstyled' role='presentation'>" + symbolList + "</ul>" );
Garneauma marked this conversation as resolved.
Show resolved Hide resolved
$( "#sb_" + layerName + " li" ).attr( "role", "presentation" );
} else {
$( "#sb_" + layerName ).html( "<ul class='list-unstyled'>" + symbolList + "</ul>" );
}

// create the legend symbols
for ( i = 0, len = symbolItems.length; i !== len; i += 1 ) {
Expand Down
16 changes: 16 additions & 0 deletions src/plugins/geomap/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,22 @@
/**
* GeoMap
*/
.wb-geomap {
&.legend-label-only {
.geomap-lgnd-layer:has(> div > ul > li:only-child) {
display: flex;

label {
margin-right: 5px;
}

.geomap-legend-symbol-text {
display: none;
}
}
}
}

.wb-geomap-map {
outline: 1px solid #ccc;
overflow: hidden;
Expand Down
62 changes: 62 additions & 0 deletions src/plugins/geomap/demo/BusinessScaleProductivity_en.kml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8" ?>
<kml
xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Folder>
<name>Projects</name>
<Schema name="Projects" id="Projects">
<SimpleField name="OBJECTID" type="int"></SimpleField>
<SimpleField name="Project" type="string"></SimpleField>
<SimpleField name="Program" type="string"></SimpleField>
</Schema>
<Placemark>
<ExtendedData>
<SchemaData schemaUrl="#Projects">
<SimpleData name="OBJECTID">1</SimpleData>
<SimpleData name="Project">Increase operational capacity of media technology company</SimpleData>
<SimpleData name="Program">Business Scale Up</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-123.090303,49.371067</coordinates>
</Point>
</Placemark>
<Placemark>
<ExtendedData>
<SchemaData schemaUrl="#Projects">
<SimpleData name="OBJECTID">2</SimpleData>
<SimpleData name="Project">Build a Green Hydrogen Production Plant in BC</SimpleData>
<SimpleData name="Program">Business Scale Up</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-123.005664,49.158076</coordinates>
</Point>
</Placemark>
<Placemark>
<ExtendedData>
<SchemaData schemaUrl="#Projects">
<SimpleData name="OBJECTID">3</SimpleData>
<SimpleData name="Project">Expand medical device manufacturing facilities</SimpleData>
<SimpleData name="Program">Business Productivity</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-123.007287,49.206271</coordinates>
</Point>
</Placemark>
<Placemark>
<ExtendedData>
<SchemaData schemaUrl="#Projects">
<SimpleData name="OBJECTID">4</SimpleData>
<SimpleData name="Project">Expand sales and manufacturing capacity for biodegradable consumer product producer</SimpleData>
<SimpleData name="Program">Business Productivity</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-119.494117,49.889315</coordinates>
</Point>
</Placemark>
</Folder>
</Document>
</kml>
62 changes: 62 additions & 0 deletions src/plugins/geomap/demo/BusinessScaleProductivity_fr.kml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8" ?>
<kml
xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Folder>
<name>Projets</name>
<Schema name="Projects" id="Projects">
<SimpleField name="OBJECTID" type="int"></SimpleField>
<SimpleField name="Project" type="string"></SimpleField>
<SimpleField name="Program" type="string"></SimpleField>
</Schema>
<Placemark>
<ExtendedData>
<SchemaData schemaUrl="#Projects">
<SimpleData name="OBJECTID">1</SimpleData>
<SimpleData name="Project">Augmenter la capacité opérationnelle de l'entreprise de technologie médiatique</SimpleData>
<SimpleData name="Program">Expansion des entreprises</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-123.090303,49.371067</coordinates>
</Point>
</Placemark>
<Placemark>
<ExtendedData>
<SchemaData schemaUrl="#Projects">
<SimpleData name="OBJECTID">2</SimpleData>
<SimpleData name="Project">Construire une usine de production d’hydrogène vert en Colombie-Britannique</SimpleData>
<SimpleData name="Program">Expansion des entreprises</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-123.005664,49.158076</coordinates>
</Point>
</Placemark>
<Placemark>
<ExtendedData>
<SchemaData schemaUrl="#Projects">
<SimpleData name="OBJECTID">3</SimpleData>
<SimpleData name="Project">Agrandir les installations de fabrication de dispositifs médicaux</SimpleData>
<SimpleData name="Program">Productivité des entreprises</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-123.007287,49.206271</coordinates>
</Point>
</Placemark>
<Placemark>
<ExtendedData>
<SchemaData schemaUrl="#Projects">
<SimpleData name="OBJECTID">4</SimpleData>
<SimpleData name="Project">Augmenter la capacité de vente et de fabrication du producteur de produits de consommation biodégradables</SimpleData>
<SimpleData name="Program">Productivité des entreprises</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-119.494117,49.889315</coordinates>
</Point>
</Placemark>
</Folder>
</Document>
</kml>
62 changes: 62 additions & 0 deletions src/plugins/geomap/demo/RegionalInnovationEcosystem_en.kml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8" ?>
<kml
xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Folder>
<name>Projects</name>
<Schema name="Projects" id="Projects">
<SimpleField name="OBJECTID" type="int"></SimpleField>
<SimpleField name="Project" type="string"></SimpleField>
<SimpleField name="Program" type="string"></SimpleField>
</Schema>
<Placemark>
<ExtendedData>
<SchemaData schemaUrl="#Projects">
<SimpleData name="OBJECTID">3</SimpleData>
<SimpleData name="Project">Create an Agtech Innovation Sandbox (AGIS) to scale up and commercialize agtech in BC</SimpleData>
<SimpleData name="Program">Regional Innovation Ecosystems</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-122.848782,49.187925</coordinates>
</Point>
</Placemark>
<Placemark>
<ExtendedData>
<SchemaData schemaUrl="#Projects">
<SimpleData name="OBJECTID">6</SimpleData>
<SimpleData name="Project">Grow BC biotech by advancing in-vitro and in-situ antiviral therapy for SARS-CoV2 variants</SimpleData>
<SimpleData name="Program">Regional Innovation Ecosystems</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-123.245686,49.263306</coordinates>
</Point>
</Placemark>
<Placemark>
<ExtendedData>
<SchemaData schemaUrl="#Projects">
<SimpleData name="OBJECTID">9</SimpleData>
<SimpleData name="Project">Establish the BC Net-Zero Innovation Network</SimpleData>
<SimpleData name="Program">Regional Innovation Ecosystems</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-122.776649,49.26575355</coordinates>
</Point>
</Placemark>
<Placemark>
<ExtendedData>
<SchemaData schemaUrl="#Projects">
<SimpleData name="OBJECTID">22</SimpleData>
<SimpleData name="Project">Grow BC biotech by improving the delivery technology behind the mRNA vaccines</SimpleData>
<SimpleData name="Program">Regional Innovation Ecosystems</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-123.249624,49.260613</coordinates>
</Point>
</Placemark>
</Folder>
</Document>
</kml>
62 changes: 62 additions & 0 deletions src/plugins/geomap/demo/RegionalInnovationEcosystem_fr.kml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8" ?>
<kml
xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Folder>
<name>Projets</name>
<Schema name="Projects" id="Projects">
<SimpleField name="OBJECTID" type="int"></SimpleField>
<SimpleField name="Project" type="string"></SimpleField>
<SimpleField name="Program" type="string"></SimpleField>
</Schema>
<Placemark>
<ExtendedData>
<SchemaData schemaUrl="#Projects">
<SimpleData name="OBJECTID">3</SimpleData>
<SimpleData name="Project">Créer un Agtech Innovation Sandbox (AGIS) pour développer et commercialiser l'agtech en Colombie-Britannique</SimpleData>
<SimpleData name="Program">Écosystèmes d&apos;innovation régionaux</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-122.848782,49.187925</coordinates>
</Point>
</Placemark>
<Placemark>
<ExtendedData>
<SchemaData schemaUrl="#Projects">
<SimpleData name="OBJECTID">6</SimpleData>
<SimpleData name="Project">Développez la biotechnologie de la Colombie-Britannique en faisant progresser la thérapie antivirale in vitro et in situ pour les variantes du SRAS-CoV2</SimpleData>
<SimpleData name="Program">Écosystèmes d&apos;innovation régionaux</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-123.245686,49.263306</coordinates>
</Point>
</Placemark>
<Placemark>
<ExtendedData>
<SchemaData schemaUrl="#Projects">
<SimpleData name="OBJECTID">9</SimpleData>
<SimpleData name="Project">Établir le réseau d’innovation de la Colombie-Britannique Net-Zero</SimpleData>
<SimpleData name="Program">Écosystèmes d&apos;innovation régionaux</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-122.776649,49.26575355</coordinates>
</Point>
</Placemark>
<Placemark>
<ExtendedData>
<SchemaData schemaUrl="#Projects">
<SimpleData name="OBJECTID">22</SimpleData>
<SimpleData name="Project">Développer la biotechnologie de la Colombie-Britannique en améliorant la technologie d'administration derrière les vaccins à ARNm</SimpleData>
<SimpleData name="Program">Écosystèmes d&apos;innovation régionaux</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-123.249624,49.260613</coordinates>
</Point>
</Placemark>
</Folder>
</Document>
</kml>
62 changes: 62 additions & 0 deletions src/plugins/geomap/demo/WesternDiversificationProgram_en.kml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8" ?>
<kml
xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Folder>
<name>Projects</name>
<Schema name="Projects" id="Projects">
<SimpleField name="OBJECTID" type="int"></SimpleField>
<SimpleField name="Project" type="string"></SimpleField>
<SimpleField name="Program" type="string"></SimpleField>
</Schema>
<Placemark>
<ExtendedData>
<SchemaData schemaUrl="#Projects">
<SimpleData name="OBJECTID">8</SimpleData>
<SimpleData name="Project">Implement a disaster recovery and economic adjustment initiative in British Columbia</SimpleData>
<SimpleData name="Program">CEDD (formerly known as WDP)</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-122.292378,49.145325</coordinates>
</Point>
</Placemark>
<Placemark>
<ExtendedData>
<SchemaData schemaUrl="#Projects">
<SimpleData name="OBJECTID">39</SimpleData>
<SimpleData name="Project">Establish an Indigenous Innovative Bioeconomy Demonstration Program in BC</SimpleData>
<SimpleData name="Program">CEDD (formerly known as WDP)</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-123.24746,49.261224</coordinates>
</Point>
</Placemark>
<Placemark>
<ExtendedData>
<SchemaData schemaUrl="#Projects">
<SimpleData name="OBJECTID">122</SimpleData>
<SimpleData name="Project">Deliver Rural &amp; Northern Immigration Pilot in North Okanagan, West Kootenay &amp; Shuswap, BC</SimpleData>
<SimpleData name="Program">CEDD (formerly known as WDP)</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-119.261665,50.282286</coordinates>
</Point>
</Placemark>
<Placemark>
<ExtendedData>
<SchemaData schemaUrl="#Projects">
<SimpleData name="OBJECTID">201</SimpleData>
<SimpleData name="Project">Enhance Small Business BC&amp;s BC Marketplace to support diversity and inclusiveness</SimpleData>
<SimpleData name="Program">CEDD (formerly known as WDP)</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-123.1044603,49.24362229</coordinates>
</Point>
</Placemark>
</Folder>
</Document>
</kml>