leafle
1 Topic[R] Leaflet Visual works on Desktop, breaks on Service
Hello fellow developers, i have developed a custom R Visual (leaflet map) in Power BI using R Studio. The visual works just as intended on Desktop Version but once i publish the dashboard to services, it seems to run different code. I'm on directQuery mode so the datasource is the same locally as on service. Yes i have matched the recommended Versions for leaflet (2.2.2) and R (4.3.3) on my local instance. I don't use any more packages or crazy functions, everything is build in R functionality. I basically have this dataframe: df <- data.frame( Latitude[,1], Longitude[,1], Timestamp[,1], Layers ) Lat and Long values + a (field) parameter that allows me to pass certain layers to the visual. These layers (columns) are booleans and if set to True the lat long value will be kept, if it is set to false the lat long value will be dropped. #Get only the extra layers (not the lat longs and timestamp): extra_columns <- setdiff(colnames(Layers), c("timestamp", "geo_lat", "geo_long")) # If there are NA values they will be dropped: df <- df[rowSums(is.na(df) | df == "") == 0, ] # For each Layer i need to convert the string "True"/"False" into a boolean True /False for (col in extra_columns) { if (col %in% colnames(df)) { df[[col]] <- as.logical(ifelse(is.na(df[[col]]), FALSE, df[[col]])) } } Now i create one map layer per extra column with the respective True/False Filtering of that column. for (col in extra_columns) { filtered_data <- df[df[[col]] == TRUE, ] num_points <- nrow(filtered_data) if (num_points > 0) { layer_color <- generate_random_color() layer_colors[[col]] <- layer_color layer_labels[[col]] <- col map <- map %>% addCircleMarkers( lng = filtered_data$Longitude, lat = filtered_data$Latitude, radius = 5, color = layer_color, stroke = FALSE, fillOpacity = 0.8, group = col, label = ~paste("colnames: ", colnames(filtered_data)) %>% lapply(htmltools::HTML) ) } } This works perfectly when locally executed, however once published it seems that there is no filtering and for what reason ever i get all datapoints on every layer. I have no idea why though.Solved1.4KViews0likes2Comments