Skip to content

Commit

Permalink
Support config for Feature Info panel in Cesium
Browse files Browse the repository at this point in the history
- Allow configuration of a feature template in a Map Asset model
- Add a 'table' (default) and 'story' feature template
- Allow configuration custom properties in a Map Asset model (dates and strings)
- Tweak the text shown for the title and button in FeatureInfoView
- Add Day.JS library for formatting dates

Relates to #1797
  • Loading branch information
robyngit committed Dec 10, 2021
1 parent cbe39bb commit 451d93e
Show file tree
Hide file tree
Showing 13 changed files with 654 additions and 97 deletions.
18 changes: 17 additions & 1 deletion docs/guides/maps/cesium.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,20 @@ Below is an example of a detailed map configuration (descriptions have been shor
"label": "Some Test GeoJSON",
"type": "GeoJsonDataSource",
"description": "A single point specified using GeoJSON",
"customProperties": {
"year": {
"type": "date",
"property": "dateAndTime",
"format": "YYYY"
}
},
"featureTemplate": {
"template": "story",
"label": "year",
"options": {
"description": "summary",
}
},
"cesiumOptions": {
"data": {
"type": "FeatureCollection",
Expand All @@ -227,7 +241,9 @@ Below is an example of a detailed map configuration (descriptions have been shor
"coordinates": [102.0, 0.5]
},
"properties": {
"prop0": "value0"
"prop0": "value0",
"dateAndTime": "2007-03-01T13:00:00Z",
"summary": "This is an example point!"
}
}
]
Expand Down
Binary file modified docs/screenshots/views/maps/FeatureInfoView.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/components/dayjs.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 64 additions & 18 deletions src/css/map-view.css
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
/* hide the credits until we can find a better placement for them */
.cesium-widget-credits, .cesium-credit-lightbox-overlay {
display: none !important;
}
}


/*****************************************************************************************
Expand All @@ -125,10 +125,11 @@
display: grid;
box-sizing: border-box;
}

/* On larger screens, the toolbar should 'squish' the map, not overlap it */
@media only screen and (min-width: 768px) {
.map-view{
grid-template-columns: auto minmax(0,100%);
.map-view {
grid-template-columns: auto minmax(0, 100%);
justify-content: start;
}
}
Expand All @@ -144,6 +145,7 @@
width: 100%;
height: 100%;
}

/* So the map widget is underneath the links/tabs on larger screens (the toolbar should 'squish' the map, not overlap it) */
@media only screen and (min-width: 768px) {
.map-view__map-widget-container {
Expand All @@ -170,6 +172,7 @@
/* required to be placed above map widget in firefox: */
z-index: 1;
}

/* On large screens, the toolbar should not overlap the map, it should squish it */
@media only screen and (min-width: 768px) {
.map-view__toolbar-container {
Expand Down Expand Up @@ -447,7 +450,7 @@ represents 1 unit of the given distance measurement. */
opacity: 0.8;
}

.layer-item__icon > svg {
.layer-item__icon>svg {
height: 100%;
width: auto;
}
Expand Down Expand Up @@ -692,7 +695,11 @@ other class: .ui-slider-range */
*
* Feature Info
*
* The box that shows more information about a feature that a user clicks
* The box that shows more information about a feature that a user clicks. The content is
* formatted according to a configurable template. Available templates include:
*
* - table: A 2 column table that lists the key and value for each of the properties in a feature
* - story: Intended to display a user friendly summary of the data in the feature. Includes a title, sub-title, description, image and link.
*
*/

Expand All @@ -701,12 +708,12 @@ other class: .ui-slider-range */
border-top-right-radius: var(--map-border-radius);
border-top-left-radius: var(--map-border-radius);
padding: 1rem 0.8rem 1rem 0.8rem;
row-gap: 1rem;
row-gap: 0.8rem;
background-color: var(--map-col-bkg-lighter);
color: var(--map-col-text);
box-shadow: var(--map-shadow-md);
grid-template-columns: auto 2.5rem;
grid-template-rows: min-content 1fr min-content;
grid-template-rows: min-content auto min-content;
justify-items: center;
/* Don't show the details panel unless it also has the feature-info--open class */
display: none;
Expand All @@ -726,7 +733,6 @@ other class: .ui-slider-range */
font-weight: 500;
font-size: 0.9rem;
opacity: 60%;
padding-left: 2.5rem;
}

.feature-info__content {
Expand All @@ -735,7 +741,7 @@ other class: .ui-slider-range */
grid-template-columns: 100%;
gap: 1rem;
grid-column: 1 / 3;
padding-bottom: 1rem;
padding-bottom: 0.5rem;
overflow: scroll;
}

Expand All @@ -747,12 +753,19 @@ other class: .ui-slider-range */
justify-self: end;
}

.feature-info__layer-details-button {
grid-column: 1 / 3;
}


/* styles for the (default) table template */

.feature-info__table {
/* TODO: use colour vars */
background-color: var(--map-col-bkg-lightest);
border-radius: var(--map-border-radius);
box-shadow: var(--map-shadow-md);
width: calc(var(--map-width-toolbar) - 4rem);
width: calc(var(--map-width-toolbar) - 2.2rem);
}

.feature-info__table-body {}
Expand All @@ -771,13 +784,47 @@ other class: .ui-slider-range */
padding: 0.6rem;
overflow-wrap: break-word;
word-wrap: break-word;
max-width: calc( (var(--map-width-toolbar)/2) - 1rem );
max-width: calc((var(--map-width-toolbar)/2) - 1rem);
}

.feature-info__layer-details-button {
grid-column: 1 / 3;
/* styles for the story template */

.feature-info__thumbnail {
min-width: 6rem;
min-height: 6rem;
max-width: 50%;
float: right;
margin: 0.3rem;
border-radius: var(--map-border-radius);
box-shadow: var(--map-shadow-md);

}

.feature-info__subtitle {
font-size: 0.9em;
text-transform: uppercase;
display: block;
opacity: 0.85;
margin: 0;
padding: 0;
}

.feature-info__description {
margin: 0.55rem 0;
font-size: 0.9rem;
line-height: 1.4rem;
}

.feature-info__link {
text-transform: uppercase;
font-size: 0.9rem;
display: flex;
align-items: center;
font-weight: bold;
text-decoration: none;
}


/*****************************************************************************************
*
* Map Legend
Expand All @@ -786,17 +833,17 @@ other class: .ui-slider-range */
*
*/

.map-legend--preview{
.map-legend--preview {
height: 1.2rem;
width: 100%
}

.map-legend__svg--preview{
.map-legend__svg--preview {
height: 100%;
width: auto;
}

.map-legend__img--preview{
.map-legend__img--preview {
--img-overflow: 0.8rem;
/* allow images previews to bleed into the padding a little, so that more detail is visible */
height: calc(100% + var(--img-overflow));
Expand All @@ -806,5 +853,4 @@ other class: .ui-slider-range */
box-shadow: var(--map-shadow-md);
/* imagery appears lighter on the map */
filter: brightness(1.75);
}

}
2 changes: 1 addition & 1 deletion src/js/models/maps/Feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ define(
* @property {*} featureObject The object that a Map widget uses to represent this
* feature in the map. For example, in Cesium this could be a
* Cesium.Cesium3DTileFeature or a Cesium.Entity.
* @property {string} label An optional friendly label for this feature.
* @property {string} label An optional friendly label or name for this feature.
*/
defaults: function () {
return {
Expand Down
6 changes: 3 additions & 3 deletions src/js/models/maps/assets/Cesium3DTileset.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,17 @@ define(
*/
getPropertiesFromFeature(feature) {
try {
const properties = {};
let properties = {};
feature.getPropertyNames().forEach(function (propertyName) {
properties[propertyName] = feature.getProperty(propertyName)
})
properties = this.addCustomProperties(properties)
return properties
}
catch (error) {
console.log(
'There was an error getting properties from a A Cesium 3D Tile feature' +
'. Error details: ' + error +
'. Returning an empty object.'
'. Error details: ' + error + '. Returning an empty object.'
);
return {}
}
Expand Down
1 change: 1 addition & 0 deletions src/js/models/maps/assets/CesiumVectorData.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ define(
if (featureProps) {
properties = feature.properties.getValue(new Date())
}
properties = this.addCustomProperties(properties)
return properties
}
catch (error) {
Expand Down
Loading

0 comments on commit 451d93e

Please sign in to comment.