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

"dev mode" that displays map properties #238

Closed
MilesMcBain opened this issue Nov 14, 2019 · 18 comments
Closed

"dev mode" that displays map properties #238

MilesMcBain opened this issue Nov 14, 2019 · 18 comments
Labels
enhancement New feature or request

Comments

@MilesMcBain
Copy link

MilesMcBain commented Nov 14, 2019

What do you want the feature to do?
Display me the current zoom level, pitch, aspect, and location of the mapdeck map.

From digging around in the JS console, these are available at run time through a call like:

window['htmlwidget-61c5ac303a9850ca1046map'].viewState

The idea is this would help the developer frame up the default views for dashboards, reports, etc.

Similar examples
mapview displays the current cursor long lat and zoom.

@MilesMcBain MilesMcBain added the enhancement New feature or request label Nov 14, 2019
@SymbolixAU
Copy link
Collaborator

SymbolixAU commented Nov 14, 2019

Display me the current zoom level, pitch, aspect, and location of the mapdeck map.

Are you wanting this displayed in the javascript console?


If you're in shiny mode you can observe the view changes using

observeEvent({intput$myMap_view_change},{
  ## do something with input$myMap_view_change
})

@SymbolixAU
Copy link
Collaborator

mapview displays the current cursor long lat and zoom.

And do you know where in the code this happens?

@tim-salabim
Copy link

the code for the mousecoordinates is here:

https://github.com/r-spatial/leafem/blob/master/R/mousecoords.R#L53-L167

@dcooley
Copy link
Collaborator

dcooley commented Nov 14, 2019

Thanks @tim-salabim - I now understand!

@tim-salabim
Copy link

@dcooley I am still planning to integrate mapdeck in mapview as a rendering platform. Maybe this is a good point to start the process... We can either expand the mousecoords above to work also on mapdeck objects or have something similar in mapdeck itself and I'll wrap it in the above. Also, it may be desirable to transfer the text based onRender solution to a native JavaScript plugin (seems more elegant and better to debug). Let me know what you think

@SymbolixAU
Copy link
Collaborator

@tim-salabim I think Mile's suggestion of using the viewState object is the best approach for Deckgl, as it always exists and I just have to read its properties.

Still keen on supporting getting it working in mapview. Are you going to Rstudio::conf?

@tim-salabim
Copy link

tim-salabim commented Nov 15, 2019

Perfect, that'll make it easy for me to wrap it.

To get mapdeck + mapview on the way, the most important function to expand is leafem::addFeatures which, on first inspection, shouldn't be too hard.

Hopefully I will find some time over the coming weeks to get this done.

@dcooley
Copy link
Collaborator

dcooley commented Nov 15, 2019

@MilesMcBain were you thinking this feature would only be used for developing & debugging?

Here's a quick example which prints the current viewState object, and updates every time you pan, zoom, drag the map

Screen Shot 2019-11-15 at 8 57 03 pm

dcooley added a commit that referenced this issue Nov 15, 2019
tim-salabim added a commit to r-spatial/leafem that referenced this issue Nov 15, 2019
@tim-salabim
Copy link

tim-salabim commented Nov 15, 2019

That was easier than anticipated! Right now leafem::addFeatures uses:

  • add_pointcloud for point features (i.e. sfc_*POINT) - though elevation argument doesn't seem to be respected for sf data
  • add_path for line features
  • add_polygon for polygon features

E.g. for points:

Screenshot from 2019-11-15 21-24-13

Maybe there is some smart way of letting the user choose how to render different features given that mapdeck has multiple ways of rendering e.g. lines.

The only requirement for leafem::addFeatures is a valid sf/sp object. So everything that mapdeck supports for these types should be supported in leafem::addFeatures via ...

This is a major step towards supporting mapdeck in mapview. What's left is automatic popup generation (in package leafpop) and a default map setup (in package mapview).

@dcooley
Copy link
Collaborator

dcooley commented Nov 15, 2019

Maybe you could use the same rules I apply for add_sf ?

@tim-salabim
Copy link

I'll look into those.

@MilesMcBain
Copy link
Author

MilesMcBain commented Nov 17, 2019

were you thinking this feature would only be used for developing & debugging?

That's the usecase yes, only used transiently, so appearance not that important. For context, I do a lot of embedding maps in HTML reports made with RMarkdown.

So right now, once I have a mapdeck with layers just so, I then have a bit of a time puzzling out a nice default view. My go to currently is mapview or sometimes mapedit which gets me a location and zoom. I don't have anything for pitch and aspect though, so that's usually a bit of trial and error that can consume time.

edit: spurious words

@tim-salabim
Copy link

From a mapview point of view I'd be grateful if we could specify which of the information to query/display. E.g. current view bounds are not important as they presumably depend on the current window size. Hope this is not asking too much.

@SymbolixAU
Copy link
Collaborator

@MilesMcBain If you want to try it out you can grab it from

devtools::install_gihtub("SymbolixAU/mapdeck", ref = "issue238")

@tim-salabim I'll take it into consideration, thanks.

@SymbolixAU
Copy link
Collaborator

@MilesMcBain Does this add_view_state() function work as you intended?

@MilesMcBain
Copy link
Author

Yes it does! Thank you very much 😄

@SymbolixAU
Copy link
Collaborator

Cool - I'll get it documented and into master

SymbolixAU pushed a commit that referenced this issue Jan 15, 2020
@SymbolixAU
Copy link
Collaborator

Noting here - #211 (comment) - the impact to this issue should be minimal as the data is just printed to the map/screen.

@SymbolixAU SymbolixAU removed their assignment Jan 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants