自动打开Goog​​le Map和Streetview [英] Automatically open both Google Map and Streetview

查看:119
本文介绍了自动打开Goog​​le Map和Streetview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一个比我在R Shiny更好的人可以告诉我以下是否可能(可能不是,但我想知道,如果没有)。



问题:我可以在Shiny中打开谷歌地图和互动街景吗?



为什么我要这样做:



我有一个来自googleway软件包闪亮集成的编程谷歌地图。它看起来如下(代码在底部):



在我的闪亮应用中,我可以点击并从街角的图标中拖动街景家伙:





导致街景:



我想要在操作按钮或标签点击上直接跳到此街景视图而不是让用户执行拖放过程,这样我就可以将地图放在一个闪亮的标签中,直接放到另一个标签中的交互式街景中,或者更好的是马p和streetview并排在一起(链接到这里:



注释




  • 如果您的初始位置不直接落在有效的街景上位置,街景页面将为空白


I'm wondering if someone better than I am at R Shiny could tell me if the following is possible (it may not be, but I'd like to know if not).

Question: Can I open both a google map and interactive streetview in Shiny?

Why I want to do this:

I have a programmed google map coming from the googleway package shiny integration. It looks as below (code at the bottom):

In my shiny app, I can click and drag the streetview guy in the from the icon in the corner:

Resulting in the streetview:

I'd like to jump straight into this street view on an action button or tab click instead of making the user do the drag and drop process, so that I can have the map in one shiny tab and directly into the interactive streetview in another tab, or better yet have the map and streetview side by side as in (link here: https://developers.google.com/maps/documentation/javascript/examples/streetview-simple).

Is there a way to do this?

I am also looking into googleway package to see if there is another way, but as far as I can tell I can get into an interactive panorama but not street view directly. I am also looking into the possibility of using the html integration in shiny to go directly into Street View service.

Code (simplified, but tested):

library(googleway)
library(shiny)

gpscoordlat <- 39.647806
gpscoordlon <- -104.940230
markerpointsplace <- data.frame(
  lat=c(gpscoordlat),
  lon=c(gpscoordlon)
)

ui <- fluidPage(google_mapOutput("map"))


server <- function(input, output, session){

 ###Use Your API key here###
  api_key <- "GoogleAPIKeyHere"


  output$map <- renderGoogle_map({
    google_map(location=c(gpscoordlat, gpscoordlon), key= api_key, zoom=15) %>%
      add_markers(data=markerpointsplace , update_map_view= FALSE)

  })
}
shinyApp(ui, server)

解决方案

Caution

This functionality is currently under development. Progress can be tracked directly on github, but I will endeavour to update this post as I go along.

You can install the development version using

devtools::install_github("SymbolixAU/googleway")


Example

Here's an example of two maps, both controlled by the same street-view 'pegman'.

Note the two UI outputs, the standard map output, and another one I've called pano. This pano is then used in the split_view argument to google_map()

library(shiny)
library(shinydashboard)
library(googleway)

ui <- dashboardPage(

  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(
    box(width = 6,
      google_mapOutput(outputId = "map")
    ),
    box(width = 6,
        google_mapOutput(outputId = "pano")
    )
  )
)

server <- function(input, output) {
  set_key("map_api_key")

  output$map <- renderGoogle_map({
    google_map(location = c(-37.817386, 144.967463), 
             zoom = 12, 
             split_view = "pano")
  })
}

shinyApp(ui, server)

Notes

  • if your initial location doesn't fall directly on a valid 'street view' location, the streetview page will be blank

这篇关于自动打开Goog​​le Map和Streetview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆