css - 谷歌地图(街景)嵌入一个div,全屏坏了

标签 css google-maps

我有一个谷歌地图街景,效果很好:

<div class=\"street_view\" data-address = "30 Rockefeller Center" ></div>

我使用 google maps API 来定位和渲染 map (coffeescript)

# initialize google street view
  init_street_views = () ->
    $(".street_view").each ->
      address = $(@).data('address')
      div = @
      geocoder.geocode { address: address }, (results, status) ->
        if status == 'OK'
          ll = results[0].geometry.location
          svs.getPanorama {
            location: ll
            preference: 'nearest'
          }, (data, status) ->
            pos = data.location.latLng
            head = google.maps.geometry.spherical.computeHeading(pos, ll)
            panorama = new (google.maps.StreetViewPanorama)(div,
            pano: data.location.pano
            pov:
              heading: head
              pitch: 0)
            return
        return

一切正常:

streetview_1

但是,当我单击全屏按钮时,它并没有占据全屏,它似乎只占据了一个它的父容器:

enter image description here

我需要在父容器中使用 css 来让街景小部件占据整个页面吗?

最佳答案

类应该在 CSS 中这样声明:

.street_view{
background: red;
}

然后你像这样在你的 div 中使用它:

<div class="street_view">Your content</div>

所以我想你的问题是指你在 div 中的语法。整个全屏的东西都是从 JS 开始的,但是它的样式是在你的 CSS 类中声明的,所以这可能是你的问题:

<div class=\"street_view\"

另一个解决方案可能是仅在以下代码时检查您的 JS 代码:<div class=\"street_view\"提供给您的是 Google。

编辑:

我已经通过这个 Google's link 检查了包含 map 的 iframe

检查这里的代码,确保你的 map 是这样的:

<iframe width="425" height="240" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://developers.google.com/maps/documentation/javascript/examples/full/streetview-embed" allowfullscreen="">
</iframe>

关于css - 谷歌地图(街景)嵌入一个div,全屏坏了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49775379/

相关文章:

google-maps - Google Distance Matrix API - 在没有 Google map 的情况下使用该服务

php - 我如何在 Safari 浏览器中支持 <video>?

html - Safari 8 中的 Div CSS 背景颜色

css - Fabric React 和 CSS 转换 translateX

javascript - 更改 tomchentw react-google-maps 中的图钉颜色?

java - 如何修复模糊的自定义标记 Android google map api

iphone - 哪个谷歌地图版本适用于 ios 5

javascript - 如何将我的 Google map 变成图像?并且不能使用鼠标移动?

jquery - 避免感叹号框自动完成 jquery 小部件

html - 在较小的设备上查看时如何在顶部中心显示 Logo