Skip to content

Commit

Permalink
prototype for #211
Browse files Browse the repository at this point in the history
  • Loading branch information
SymbolixAU committed Jul 11, 2019
1 parent 759b106 commit 7268fd8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
43 changes: 42 additions & 1 deletion inst/htmlwidgets/mapdeck.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@ HTMLWidgets.widget({

md_setup_window( el.id );

/*
// controller with events
const myController = new deck.Controller({
handleEvent(event) {
console.log( "event" );
console.log( event );
if( event.type == "zoom") {
console.log("zooming");
}
}
});
console.log( myController );
*/

// INITIAL VIEW
window[el.id + 'INITIAL_VIEW_STATE'] = {
longitude: x.location[0],
Expand Down Expand Up @@ -39,10 +56,33 @@ HTMLWidgets.widget({
//initialViewState: window[el.id + 'INITIAL_VIEW_STATE'],
viewState: window[el.id + 'INITIAL_VIEW_STATE'],
layers: [],
//controller: myController
//onLayerHover: setTooltip
onViewStateChange: ({viewState}) => {
if (!HTMLWidgets.shinyMode) {
return;
}
Shiny.onInputChange(el.id + '_view_change', viewState);
}
});


//deckgl.setProps({viewState: window[el.id + 'INITIAL_VIEW_STATE']});
window[el.id + 'map'] = deckgl;

console.log( deckgl );

/*
console.log( deckgl._onViewStateChange );
var myListener = function(evt) {
console.log("evt");
console.log( evt );
}
document.addEventListener(onViewStateChange(deckgl), myListener, false);
*/

}
// https://github.com/uber/deck.gl/issues/2114
/*
Expand All @@ -65,11 +105,11 @@ HTMLWidgets.widget({

// TODO: code to re-render the widget with a new size
}

};
}
});


if (HTMLWidgets.shinyMode) {

Shiny.addCustomMessageHandler("mapdeckmap-calls", function (data) {
Expand Down Expand Up @@ -106,3 +146,4 @@ if (HTMLWidgets.shinyMode) {
}
});
}

2 changes: 2 additions & 0 deletions inst/htmlwidgets/mapdeck_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ function md_initialise_map(el, x) {
}
}
}

}



function md_findObjectElementByKey(array, key, value ) {
for ( var i = 0; i < array.length; i++) {
if (array[i][key] === value) {
Expand Down

0 comments on commit 7268fd8

Please sign in to comment.