Skip to content

Commit

Permalink
globalThis #357
Browse files Browse the repository at this point in the history
  • Loading branch information
galileo galilei committed May 24, 2022
1 parent 878aaff commit 8b0ff5c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: mapdeck
Type: Package
Title: Interactive Maps Using 'Mapbox GL JS' and 'Deck.gl'
Version: 0.3.40003
Version: 0.3.40004
Date: 2020-10-28
Authors@R: c(
person("David", "Cooley", ,"[email protected]", role = c("aut", "cre"))
Expand Down
2 changes: 1 addition & 1 deletion R/mapdeck_dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ deckgl_min_js <- function() {
list(
createHtmlDependency(
name = "deckgl",
version = "8.7.8",
version = "8.7.10",
src = system.file("htmlwidgets/lib/", package = "mapdeck"),
script = c("deckgl.min.js"),
all_files = FALSE
Expand Down
4 changes: 2 additions & 2 deletions inst/htmlwidgets/lib/deckgl.min.js

Large diffs are not rendered by default.

31 changes: 20 additions & 11 deletions inst/htmlwidgets/mapdeck.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@

// issue 357
if( typeof globalThis === 'undefined') {
var globalThis = window;
}


HTMLWidgets.widget({

name: 'mapdeck',
type: 'output',

factory: function(el, width, height) {

var deckgl;

return {

renderValue: function(x) {

md_setup_window( el.id );

if( x.show_view_state ) {
md_setup_view_state( el.id );
window[el.id + 'mapViewState'] = document.createElement("div");
window[el.id + 'mapViewState'].setAttribute('id', el.id + 'mapViewState');
window[el.id + 'mapViewState'].setAttribute('class', 'mapViewState');
var mapbox_ctrl = document.getElementById( "mapViewStateContainer"+el.id);
mapbox_ctrl.appendChild( window[el.id + 'mapViewState'] );
if( x.show_view_state ) {
md_setup_view_state( el.id );
window[el.id + 'mapViewState'] = document.createElement("div");
window[el.id + 'mapViewState'].setAttribute('id', el.id + 'mapViewState');
window[el.id + 'mapViewState'].setAttribute('class', 'mapViewState');
var mapbox_ctrl = document.getElementById( "mapViewStateContainer"+el.id);
mapbox_ctrl.appendChild( window[el.id + 'mapViewState'] );
}

// INITIAL VIEW
Expand All @@ -34,7 +43,7 @@ HTMLWidgets.widget({
};

if( x.access_token === null ) {
const deckgl = new deck.DeckGL({
deckgl = new deck.DeckGL({
views: [ new deck.MapView({
id: el.id,
repeat: x.repeat_view
Expand All @@ -48,7 +57,7 @@ HTMLWidgets.widget({
});
window[el.id + 'map'] = deckgl;
} else {
const deckgl = new deck.DeckGL({
deckgl = new deck.DeckGL({
views: [ new deck.MapView({
id: el.id,
repeat: x.repeat_view
Expand Down Expand Up @@ -123,8 +132,8 @@ HTMLWidgets.widget({

window[el.id + 'map'] = deckgl;

}
md_initialise_map(el, x);
} // end if { access_token } else { }
md_initialise_map(el, x);
},

resize: function(width, height) {
Expand Down

0 comments on commit 8b0ff5c

Please sign in to comment.