-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update map not working with shiny modal #237
Comments
Adding this script <script src='https://maps.googleapis.com/maps/api/js?key=", map_key, "&libraries=places&callback=initAutocomplete' async defer ></script>")) is giving you a conflict, because that script is already loaded when you call The solution: Remove that script, and the surrounding function it uses as the callback showModal(
modalDialog(footer = NULL, easyClose = T,
fluidPage(
HTML('<div class="form-group">
<input id="AdressNew" type="text" class="form-control" placeholder="Enter some adress">
</div> '),
HTML(paste0(" <script>
var autocomplete = new google.maps.places.Autocomplete(document.getElementById('AdressNew'));
autocomplete.addListener('place_changed', function() {
autocomplete.setFields(['place_id', 'geometry', 'name']);
var place = autocomplete.getPlace();
Shiny.setInputValue('jsGeometry', place.geometry);
});
</script>"
))
),
actionButton(inputId = 'go',label = 'submit')
)
) I've also added the observeEvent(input$go,{
df <- data.frame(
lat = input$jsGeometry$location$lat,
lng = input$jsGeometry$location$lng
)
google_map_update(map_id = "map") %>%
googleway::add_markers(data = df, lat = "lat", lon = "lng", update_map_view = T)
}) |
Thank you for this question; It made me finally understand how to properly use the auto-complete within a shiny :) |
Hi Dave! wonderful solution! works fine thank you very mush :) |
Hi!
I'm try to add a maker to the google map, the coordinates are calculated from geocoded address string provided by the user inside a modal:
this is the app code
ps: works fine without using modal ( with address input in sidebar)
Thank you
The text was updated successfully, but these errors were encountered: