How to add filters to a map

Hello,

I have a file containing the electric charging stations in France,
I managed to display them on a map and I would now like to add filters to display the terminals according to the type of socket selected for example.

Thanks in advance,

Charline

What have you tried so far? what is your specific problem?, we are more inclined towards helping you with specific coding problems rather than doing your work for you.

Could you please turn this into a self-contained REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.

If you've never heard of a reprex before, you might want to start by reading this FAQ:

Here is my code

UI :
library(shiny)
library(leaflet)
library(dplyr)

setwd("C:/Users/charl/OneDrive/Documents/Carte_Interactive")
data_carte <- read.csv2("bornes.csv", sep = ",", dec = ".")

Interface

shinyUI(fluidPage(

# Titre Appli
titlePanel("Carte Interactive Borne Electrique"),

# Creation d'une disposition avec panneau lateral et principal
sidebarLayout(
#Panneau lateral
    sidebarPanel(
        selectInput(
          inputId = "idPrise",
          label = "Type de Prise",
          choices = colnames(data_carte)[19:23]
        ),
        selectInput(
          inputId = "idpaiement",
          label = "Type de Paiement",
          choices = colnames(data_carte)[25:27]
        )
    ),

    # Panneau Principal
    mainPanel(
      h3("Carte", align = "center"),
      p(
        leafletOutput("carte_b")
      ),
      
      h4("Choisir : ", align = "left"),
      p(
        strong("Type de Prise : "),
        textOutput("prise")
      ),
      p(
        strong("Type de Paiement : "),
        textOutput("paiement")
      ),
      p(
        strong("Puissance : "),
        textOutput("puissance")
      )
       
    )
)

))

Server :

library(shiny)
library(leaflet)
library(dplyr)

Define server logic required to draw a histogram

shinyServer(function(input, output) {

output$carte_b <- renderLeaflet({
  setwd("C:/Users/charl/OneDrive/Documents/Carte_Interactive")
  data_carte <- read.csv2("bornes.csv", sep = ",", dec = ".")
  
  carte <- leaflet(data_carte)
  carte |> 
    addTiles() |> 
    fitBounds(3, 43.5, 4, 50.5) |> 
    addMarkers(lng = ~consolidated_longitude,
               lat = ~consolidated_latitude,
               popup = ~nom_station,
               clusterOptions = markerClusterOptions())
  })
  })

I created filters on the UI side but I don't know how to apply the filters on the interactive map (leaflet).

Could you conside the advice of the guide vis how to share this appropriately? As things stand, your example is not reproducible

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.