walkerke / mapgl

R interface to Mapbox GL JS v3 and Maplibre GL JS
https://walker-data.com/mapgl
Other
91 stars 5 forks source link

Produce Error Message When Render Fails #44

Closed CIOData closed 1 month ago

CIOData commented 2 months ago

I am trying to use add_circle_layer() with ~17k points, categorized by type. It fails to render when points are used altogether, but when separated by type, some types render and some types don't. I've tried everything (testing for valid st, removing duplicate geometries, checking for null geometries), but can't find any difference that is causing this behavior. Moreover, everything plots just fine using other methods in R. Having an error message to point out why the mapboxgl() map is failing to render would be helpful.

walkerke commented 2 months ago

Would you mind sharing a reprex? Also, could you open the error inspector in your web browser and let me know what the error says?

CIOData commented 2 months ago

There is no error, the map just fails to render.

locs.csv

library(tidyverse)
library(mapgl)
library(sf)

path = 'usr/bin'

setwd(path)

locs = read.csv('locs.csv', header=T) |>
    sf::st_as_sf(coords = c("longitude","latitude"), crs = 4326)

#renders
mapboxgl(style = carto_style('positron-no-labels')) |> 
    fit_bounds(locs, animate = FALSE) |> 
    add_circle_layer(
        source = subset(locs, Type == 'Toxic Release Inventory Facility'),
        id = 'this',
        circle_color = 'red',
        circle_stroke_width = 1,
        circle_stroke_color = 'black'
    )

#does not render
mapboxgl(style = carto_style('positron-no-labels')) |>
    fit_bounds(locs, animate = FALSE) |>
    add_circle_layer(
        source = subset(locs, Type == 'Lung Cancer Screening'),
        id = 'this',
        circle_color = 'red',
        circle_stroke_width = 1,
        circle_stroke_color = 'black'
    )
walkerke commented 1 month ago

@CIOData it is rendering for me:

image

I've tested in both Positron and RStudio.

What operating system are you on, and what IDE are you using? Does the map still fail to render when you pop it out into a web browser?

CIOData commented 1 month ago

Hmm, it is rendering fine for me today. I don't know what was going on before. I had even restarted the session and cleared the namespace but still had the issue. I have since restarted my computer, so some process must have been standing in the way.

Thanks for looking.

walkerke commented 1 month ago

I wonder if this is related to #43 then and there was some server-side problem going on. I'll keep an eye on it.