Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implement the Algolia Places Address Search Auto Completion Menu on Shiny Text Inputs

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
NotificationsYou must be signed in to change notification settings

feddelegrand7/algo

Repository files navigation

CRAN_Status_Badge

CRAN_time_from_release

metacran downloads

metacran downloads

license

Travis build status

R badge

Thealgo package allows you to implement theAlgoliaPlaces Address Search AutoCompletion Menu on shiny Text Inputs.

Setup

In order to use the Algolia Places JavaScript library, you’ll needcreate a freePlaces applicationin which you can get anID and anAPI KEY. When you sign up,you’ll be able to run 100,000 requests/month which is quite cool formost users.

After that, set your credentials within the.Renviron file which canbe opened with:

# install.packages("usethis")usethis::edit_r_environ()

Then, store the value of your credentials as follows:

# These credentials are fakes and used  to give you an ideaALGOLIA_ID=LSKDFNSFSDALGOLIA_KEY=29453SKVNEV43T3G3KVEEV

Finally, save your .Renviron file, close it and restart your R session.

Installation

You can install thealgo package fromCRAN with:

install.packages("algo")

You can install the development version ofalgo from Github with:

# install.packages("remotes")remotes::install_github("feddelegrand7/algo")

How to use the algo package

Thealgo package has two functions:

  • use_algolia(): you must put theuse_algolia() function at thebeginning of your shiny UI. It doesn’t take any argument. It onlyallows you to activate the Algolia Places JavaScript library.

  • algo(): you’ll implement an address search auto completion menu onany shiny text input using this function.

Example

Let’s create a basic shiny application to demonstrate the features ofthe package:

library(shiny)library(algo)ui<- fluidPage(    use_algolia(),       textInput(inputId="inp1",label="Please introduce your address",width="800px"),       algo(element="#inp1",type="address")# Don't forget to add the # to your ID  )server<-function(input,output) {}shinyApp(ui,server)

Using thetype argument you can specify which type of geographicinformation to collect:

library(shiny)library(algo)ui<- fluidPage(    use_algolia(),       textInput(inputId="inp1",label="Please introduce your country",width="800px"),     textInput(inputId="inp2",label="Now introduce your city",width="800px"),      algo(element="#inp1",type="country"),# Don't forget to add the # to your ID    algo(element="#inp2",type="city")    )server<-function(input,output) {}shinyApp(ui,server)

You can also specify in which country (or countries) you want to get theaddresses. This will set a delimitation according to the chosen country:

library(shiny)library(algo)ui<- fluidPage(    use_algolia(),       textInput(inputId="inp1",label="Where do you live in Japan ?",width="800px"),       algo(element="#inp1",type="address",countries="jp")# Don't forget to add the # to your ID    )server<-function(input,output) {}shinyApp(ui,server)

Further, you can specify which language should be displayed whencollecting the addresses (note that it will only translate partially theaddresses):

library(shiny)library(algo)ui<- fluidPage(    use_algolia(),       textInput(inputId="inp1",label="Where do you live in Spain ?",width="800px"),       algo(element="#inp1",type="city",countries="es",language="de")# Don't forget to add the # to your ID  )server<-function(input,output) {}shinyApp(ui,server)

Finally, you can collect the addresses the same way as any other shinyinputs:

library(shiny)library(algo)ui<- fluidPage(    use_algolia(),       textInput(inputId="inp1",label="Where do you live in Spain ?",width="800px"),       algo(element="#inp1",type="city",countries="es",language="de"),# Don't forget to add the # to your ID    textOutput(outputId="txt1")    )server<-function(input,output) {output$txt1<- renderText({    req(input$inp1)      paste0("I KNOW WHERE YOU LIVE O_O:",input$inp1)    })    }shinyApp(ui,server)

Code of Conduct

Please note that the algo project is released with aContributor CodeofConduct.By contributing to this project, you agree to abide by its terms.

About

Implement the Algolia Places Address Search Auto Completion Menu on Shiny Text Inputs

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp