Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dragging Javascript errors #364

Closed
dcooley opened this issue Mar 7, 2023 · 3 comments
Closed

Dragging Javascript errors #364

dcooley opened this issue Mar 7, 2023 · 3 comments

Comments

@dcooley
Copy link
Collaborator

dcooley commented Mar 7, 2023

related to #349, this seems to be happening again

e.g. - drag on the polygon

library(shinydashboard)
library(mapdeck)
library(sf)
set_token(secret::get_secret("MAPBOX"))

ui <- shinydashboard::dashboardPage(
	header = shinydashboard::dashboardHeader()
	, body = shinydashboard::dashboardBody(
		mapdeck::mapdeckOutput(
			outputId = "map"
		)
	)
	, sidebar = shinydashboard::dashboardSidebar()
)

server <- function(input, output, session) {
	
	nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"))
	
	output$map <- mapdeck::renderMapdeck({
		
		mapdeck::mapdeck() %>%
			add_polygon(
				data = nc		
			)
				
	})
}

shiny::shinyApp(ui = ui, server = server)
@dcooley
Copy link
Collaborator Author

dcooley commented Mar 7, 2023

I've disabled the drag events on the master branch while this is investigated

@dcooley
Copy link
Collaborator Author

dcooley commented Mar 8, 2023

In absence of a complete solution, I'm building a dragObject

function buildDragObject(info) {
  var dragObject = {
       coordinate: info.coordinate,
       viewport: info.viewport,
      x: info.x,
     y: info.y
   };

  return(dragObject);
}
library(shinydashboard)
library(mapdeck)
library(sf)
set_token(secret::get_secret("MAPBOX"))

ui <- shinydashboard::dashboardPage(
	header = shinydashboard::dashboardHeader()
	, body = shinydashboard::dashboardBody(
		mapdeck::mapdeckOutput(
			outputId = "map"
		)
	)
	, sidebar = shinydashboard::dashboardSidebar()
)

server <- function(input, output, session) {
	
	nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"))
	
	output$map <- mapdeck::renderMapdeck({
		
		mapdeck::mapdeck() %>%
			add_polygon(
				data = nc		
			)
	})
	
	observeEvent({input$map_drag_start}, {
		print(input$map_drag_start)
	})
	
	observeEvent({input$map_drag}, {
		print(input$map_drag)
	})
	
	observeEvent({input$map_drag_end}, {
		print(input$map_drag_end)
	})
	
}

shiny::shinyApp(ui = ui, server = server)

@dcooley
Copy link
Collaborator Author

dcooley commented Mar 8, 2023

merged in to master. Calling this a fix

@dcooley dcooley closed this as completed Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant