1
votes

I am new to Shiny and R (with database background) and would appreciate your help. I am trying to create a search tool on a map (with no Nominatim) to zoom the map to it - I have a list of streets and their lat/lon in a csv file (1800 entries).

i call them

streets <-read.csv(file = "Q:/R/streets.csv")

and then in the ui.r I use the input

selectizeInput('st', 'Street to center the map', choices =  streets)

But the control returns a list of IDs - they are just generated by the system, not in the file, so instead of let's say 'High Street' it displays '23'. The csv structure is StreetName/Lat/Lon

How can I make it displaying the streetname column? And can i make the output lat/lon (based on the street selection) or do I need to get this piece again out of the file on the server side (requerying the file)? All I need from the input is to readjust the map's central point

2
To display the street names, use choices = streets$StreetName. - Xiongbing Jin
even with choices = streets$StreetName it still presents just numbers. When I turned the header off there was a word StreetName above the numbers, so I wonder if it is not somthing related to CSV reading - it just looks like it shifted the streetname header to the numbers - Slav
try choices=as.vector(streets$StreetName) - Xiongbing Jin
excellent - this one worked, thanks a lot. Do i need to requery the data based on the street name or can i return lat/lon from the control? In many languages you can define what you want to return - Slav
BTW How can i 'rate' your response to show my appreciation? - Slav

2 Answers

1
votes

Try choices=as.vector(streets$StreetName). To make selectizeInput or selectInput return a value different from the displayed name, try choices=setnames(streets$Lat, streets$StreetName). Not sure how to make it return two numbers (lat,lon) though.

0
votes

To add to the above answer, since you have already processed the csv file and got a data frame called streets, you can directly use 'streets' to further retrieve lat/lon based on the selection of street name. Subset the data frame streets for this.