Skip to content

Commit

Permalink
draw assets for currently-selected tags
Browse files Browse the repository at this point in the history
  • Loading branch information
subelsky committed Oct 29, 2019
1 parent a88a850 commit 10276f4
Showing 1 changed file with 19 additions and 23 deletions.
42 changes: 19 additions & 23 deletions example/client_mix/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,26 +179,15 @@ function mapAssets(map,listener,roundware) {
return assetMarkers;
}

function showHideMarkers(map,assetMarkers) {
assetMarkers.forEach(item => {
// if any item tags are not included in selected tags, hide marker, otherwise show it
//const selectedListenTagIds = $("#uiListenDisplay input:checked").map(function() {
//return Number(this.value);
//}).get();

//let is_visible = true;

//const { rw_tags = [] } = item;

//rw_tags.forEach((j,tag_id) =>{
//// if tag_id isn't selected, set to false and return
//if (!(selectedListenTagIds.includes(tag_id))) {
//is_visible = false;
//return;
//}
//});
function showHideMarkers(map,assetMarkers,{ listenTagIds = [] }) {
const listenTagIdMap = listenTagIds.reduce((map,tagId) => {
map[Number(tagId)] = true;
return map;
},{});

const is_visible = true;
assetMarkers.forEach(item => {
const { rw_tags } = item;
const is_visible = !!(rw_tags.find(tagId => listenTagIdMap[tagId]));

item.setVisible(is_visible);

Expand Down Expand Up @@ -278,9 +267,7 @@ function initDemo() {
then(({ uiConfig }) => {
mapSpeakers(map,roundware);

const assetMarkers = mapAssets(map,listener,roundware);
showHideMarkers(map,assetMarkers);

const assetMarkers = mapAssets(map, listener, roundware);
const { recordingRadius = 25 } = roundware.mixParams;

let listeningCircle = drawListeningCircle(map,googleMapsCenter,recordingRadius);
Expand Down Expand Up @@ -329,6 +316,7 @@ function initDemo() {
},{ once: true });

const { listen: listenTags } = uiConfig;
const listenTagIds = [];

listenTags.forEach(tag => {
const { header_display_text, display_items } = tag;
Expand All @@ -337,7 +325,12 @@ function initDemo() {

const checkboxEls = display_items.map(item => {
const { tag_id, tag_display_text, default_state } = item;
const checkedAttrib = default_state ? 'checked' : '';
let checkedAttrib = '';

if (default_state) {
checkedAttrib = 'checked';
listenTagIds.push(tag_id);
}

return `
<label>
Expand All @@ -351,6 +344,8 @@ function initDemo() {
tagDiv.insertAdjacentHTML('beforeend',checkboxEls.join('\n'));
});

showHideMarkers(map,assetMarkers,{ listenTagIds });

document.querySelectorAll('.btnGroup').forEach(g => g.style.display = 'block');

document.querySelectorAll('[data-skip-track-id]').forEach(el => {
Expand All @@ -372,6 +367,7 @@ function initDemo() {
tagDiv.addEventListener('input',() => {
const listenTagIds = [...tagDiv.querySelectorAll('[name=tags]:checked')].map(tag => tag.value);
mixer.updateParams({ listenTagIds });
showHideMarkers(map,assetMarkers,{ listenTagIds });
});
}).
catch(err => {
Expand Down

0 comments on commit 10276f4

Please sign in to comment.