You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
filter map (or other visualization page) to a subset of the collection #103
I want to have be able to show the map & timeline for a subset of my collection as well as my full collection. The subset will be based on location (for example, I want to be able to show the map for "New York" and have a separate map for all items including New York.) I should be able to do this by editing the map-js.html like so:
`{%- assign items = items | where_exp: 'item', 'item.objectid != nil' | where_exp: 'item','item.latitude' -%}
{%- capture place -%}
{{ page.location }}
{%- endcapture -%}
{%- assign items = items[place] -%}`
But this doesn't seem to filter as expected (my New York map shows no items). Is there a recommended way to do such a thing?
That would set up the "items" as the subset you want, then you won't need to modify anything else below.
If you are creating multiple map pages in the collection, a simple approach is to create multiple copies of the "map-js.html", like "map-js-newyork.html" that contain your individual customizations.
Oh actually, I think I see what you mean better--> like you would like to be able to set the "location" in the page front matter so you could use the map layout for multiple different map pages?
So that would be possible with a quick customization of the map-js.html file-->
replace the "_includes/js/map-js.html" in your project repository with this customized version.
This version supports the options "location", "latitude", "longitude", and "zoom" in the page front matter. With no front matter, the map will be the standard CB map. To create a new customized map page with the data filtered by a specific value in the "location" column, you would add front matter options in the yml front matter of the page:
So the "location" field would have to match exactly to what you set in the location option.
You could replace == with contains if you want it to just contain the text in the location option, not exactly match.
You could replace item.location in the express with a different metadata field if desired, like item.title or item.date etc...
Activity
evanwill commentedon Nov 13, 2023
@sheishistoric you want to create a "New York" specific version of the map page that only has points for the items with "New York" as the location?
I would add that as another
where_expin the Liquid setting up the "items", after the existing ones. It would look something like:That would set up the "items" as the subset you want, then you won't need to modify anything else below.
If you are creating multiple map pages in the collection, a simple approach is to create multiple copies of the "map-js.html", like "map-js-newyork.html" that contain your individual customizations.
eastofesten commentedon Nov 14, 2023
evanwill commentedon Nov 14, 2023
Oh actually, I think I see what you mean better--> like you would like to be able to set the "location" in the page front matter so you could use the map layout for multiple different map pages?
So that would be possible with a quick customization of the map-js.html file-->
replace the "_includes/js/map-js.html" in your project repository with this customized version.
This version supports the options "location", "latitude", "longitude", and "zoom" in the page front matter. With no front matter, the map will be the standard CB map. To create a new customized map page with the data filtered by a specific value in the "location" column, you would add front matter options in the yml front matter of the page:
You could create additional pages with the "layout: map", and customize each with different options.
The version I linked above uses this Liquid to filter the items:
So the "location" field would have to match exactly to what you set in the location option.
You could replace
==withcontainsif you want it to just contain the text in the location option, not exactly match.You could replace
item.locationin the express with a different metadata field if desired, likeitem.titleoritem.dateetc...eastofesten commentedon Nov 14, 2023
Okay, yes! That's what I was thinking - thank you.
evanwill commentedon Nov 14, 2023
I am going to convert this to a Discussion in case other people want to do this!