crazycapivara / openlayers

An R Interface to OpenLayers
Other
19 stars 3 forks source link

without geojsonio? #27

Open wendellwt opened 4 years ago

wendellwt commented 4 years ago

Is it possible to use openlayers without geojsonio? I have to compile from sources, and geojsonio requires a lot of other packages such as protobuf, v8, jqr, etc. It is getting difficult to compile and install all of those. Is there a way to use openlayers for R without geojsonio?

Thanks.

crazycapivara commented 4 years ago

@wendellwt Yes, you can also use it without geojsonio. In this case you need to convert your data to geojson on your own and then pass it to add_geojson:

ol() %>%
  add_stamen_tiles() %>%
  add_geojson(
    geojsonsf::sf_geojson(nc),
    style = fill_style("yellow") + stroke_style("blue", 1),
    popup = nc$AREA
)

You may also take a look at the deckgl package where most of the layers do not require geojson as input format.

wendellwt commented 4 years ago

Thank you! The geojsonsf works fine. I almost have it working from rshiny. The first call to ol() %>% ... works, the map and markers show up, and the response it stored into output$map <- renderOl({ ol() %>% ...}). However nothing shows up on later calls to ol() %>% .... Is there some sort of redraw/refresh that needs to happen? Should the parameter to later ol() references be the name of the map div? Does output$map need to be refreshed somehow?

crazycapivara commented 4 years ago

Unfortunately I did not implement a so called proxy_object for ol that is needed to update the already rendered widget.

wendellwt commented 4 years ago

Ok, thank you.