Closed Clandboy closed 4 months ago
The problem is here (or in the corresponding minified file): https://github.com/bhaskarvk/leaflet.extras/blob/05c7e4f2cd1cf9ef586f875271cf03673c081e1d/inst/htmlwidgets/bindings/lfx-search-bindings.js#L29
options.textPlaceholder
is hardcoded, so you wont be able to change it.
Thx, so as long as it's in hard storage, I can't get control of it.
can we close the subject or wait for a development?
Yes, I would leave it opened, as the issue is not resolved yet, although it would be an easy fix. My biggest problem for changing existing bindings is how the dependencies are structured and my lack of understanding how webpack works. (Apart from the error I get when trying to run it)
For now, I could offer you a hacky solution that uses shinyjs
and changes the placeholder using Javascript.
library(shiny)
library(shinyjs)
library(leaflet)
library(leaflet.extras)
ui <- fluidPage(
useShinyjs(),
leafletOutput("map")
)
server <- function(input, output, session) {
output$map <- renderLeaflet({
p <- leaflet() %>%
addTiles() %>%
addSearchOSM(options = searchOptions(
position = "topright", collapsed = FALSE))
shinyjs::delay(300,
runjs(HTML('$("input.search-input")[0].placeholder = "Code postal - Ville"')))
p
})
}
shinyApp(ui, server)
But the filterData
should work as expected I think, but you would have to look for examples how to use it, as there is not much documentation on the original repo and I also couldnt make it work.
Thanks for the patch.
Do I have to use shiny to fix it?
Yes, but you can also use the onRender
function, which is probably more elegant and doesn't require shiny
nor shinyjs
.
library(htmlwidgets)
library(leaflet)
library(leaflet.extras)
leaflet() %>%
addTiles() %>%
addSearchOSM(options = searchOptions(
position = "topright", collapsed = FALSE)) %>%
onRender("function(el, x) {
$('input.search-input')[0].placeholder = 'Code postal - Ville'
}")
hi,
I'm in trouble with the function addSearchOSM for 2 reasons.
First one, i want to change the label in textPlaceholder, so i wrote
addSearchOSM(options = searchOptions(textPlaceholder = 'Code postal - Ville')
But it doesn't work, when i run my leaflet app, label is already "Search using..".
I screen it if it can help:
Second trouble is about filtering OSM data.. I don't understand how to make FilterDatawork
I'm trying to filter results on France only, anyone to help me ?
I also have the impression that there are some difficulties on other options of the function
Anyway, many thanks for your work and excuse my English,