Skip to content

Commit

Permalink
fixed bug in trips layer
Browse files Browse the repository at this point in the history
  • Loading branch information
dcooley committed Feb 23, 2022
1 parent 031f6bc commit 90cfe36
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 7 deletions.
3 changes: 3 additions & 0 deletions R/map_layer_trips.R
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ add_trips <- function(
experimental_layer("trips")

l <- list()

width_units <- match.arg(width_units)

l[["stroke_colour"]] <- force( stroke_colour )
l[["stroke_width"]] <- force( stroke_width )

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.6.5",
version = "8.6.8",
src = system.file("htmlwidgets/lib/", package = "mapdeck"),
script = c("deckgl.min.js"),
all_files = FALSE
Expand Down
6 changes: 3 additions & 3 deletions inst/htmlwidgets/lib/deckgl.min.js

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions inst/htmlwidgets/lib/trips/trips.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// - Can't have MultiColouredTrips because it adds too many attributes to WebGL
// - but, the way it works anyway, the colours fade into each other anyway


function add_trips_geo( map_id, map_type, path_data, opacity, layer_id,
trail_length, start_time, end_time, animation_speed, bbox, update_view, focus_layer, width_units, width_scale, width_min_pixels, width_max_pixels, legend_type ) {

//console.log(path_data);

var loopLength = end_time - start_time; // unit corresponds to the timestamp in source data
var animationSpeed = animation_speed; // unit time per second

Expand All @@ -14,13 +15,22 @@ trail_length, start_time, end_time, animation_speed, bbox, update_view, focus_la

var time = ((timestamp % loopTime) / loopTime) * loopLength;

const binaryLocation = new Float32Array( path_data.data.coordinates );
const binaryLocation = new Float64Array( path_data.data.coordinates );
const binaryStartIndices = new Uint32Array( path_data.data.start_indices );
const binaryLineColour = new Float32Array( path_data.data.data.stroke_colour );
const binaryLineWidth = new Float32Array( path_data.data.data.stroke_width );
const binaryTimestamps = new Float32Array( path_data.timestamps );

/*
console.log(binaryLocation);
console.log(binaryStartIndices);
console.log(binaryLineColour);
console.log(binaryLineWidth);
console.log(binaryTimestamps);
*/

let stride = path_data.data.stride[0];

let data_count = path_data.data.start_indices.length;

var attributes = {
Expand Down Expand Up @@ -53,6 +63,8 @@ trail_length, start_time, end_time, animation_speed, bbox, update_view, focus_la
currentTime: time
};

//console.log(layer);

var tripsLayer = new deck.TripsLayer(layer);

if( map_type == "google_map") {
Expand Down
3 changes: 2 additions & 1 deletion inst/htmlwidgets/mapdeck.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ HTMLWidgets.widget({
views: [ new deck.MapView({
id: el.id,
repeat: x.repeat_view
}) ],
})
],
mapboxApiAccessToken: x.access_token,
container: el.id,
mapStyle: x.style,
Expand Down
2 changes: 2 additions & 0 deletions inst/htmlwidgets/mapdeck_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ function md_layer_click( map_id, layer, info ) {
return;
}

console.log(info);

var eventInfo = {
index: info.index,
color: info.color,
Expand Down
1 change: 1 addition & 0 deletions man/add_geojson.Rd

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

0 comments on commit 90cfe36

Please sign in to comment.