8

我在我的 Google 地图应用上看到了一些非常奇怪的行为。我正在使用主干:

  initialize: ->
    osmMapType = new google.maps.ImageMapType(
      getTileUrl: (coord, zoom) ->
        "http://tile.openstreetmap.org/#{zoom}/#{coord.x}/#{coord.y}.png"
      tileSize: new google.maps.Size(256, 256)
      isPng: true
      alt: "OpenStreetMap layer"
      name: "OSM"
      maxZoom: 19
    )

    cloudMadeMapType = new google.maps.ImageMapType(
      getTileUrl: (coord, zoom) ->
        "http://b.tile.cloudmade.com/a97cc0871d97477b911c3f9155a93ee7/26250/256/#{zoom}/#{coord.x}/#{coord.y}.png"
      tileSize: new google.maps.Size(256, 256)
      isPng: true
      alt: "CloudMade layer"
      name: "CMade"
      maxZoom: 13
    )

    lat = 51.503
    lng = -0.113
    latlng = new google.maps.LatLng(lat, lng)
    options =
      zoom: 10
      center: latlng
      mapTypeId: 'OSM'
    @gMap = new google.maps.Map(document.getElementById("map"), options)
    @gMap.mapTypes.set('OSM', osmMapType)
    @gMap.mapTypes.set('CloudMade', cloudMadeMapType)
    @gMap.setMapTypeId(google.maps.MapTypeId.TERRAIN)

我正在加载 API:

<script src="https://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"></script>

但出于某种原因......谷歌地图控件和覆盖是“模糊的”:

模糊的控制... http://vuknikolic.wordpress.com/2012/04/02/twitter-bootstrap-and-google-maps-v3/

和一个信息窗口...

信息窗口做同样的事情

我一遍又一遍地查看了代码,看不到错误,控制台中也没有错误。


@geocodezip 是对的,它是 css。本质上,谷歌地图不喜欢 BootStrap 处理图像最大宽度的方式。所以你需要在你的 CSS 中加入一些小技巧......

#map img {
    max-width: none;
}

http://vuknikolic.wordpress.com/2012/04/02/twitter-bootstrap-and-google-maps-v3/

4

1 回答 1

10

您的代码中没有错误。这是你的css的问题。

只需在地图容器中添加这个 CSS(假设它有id=gmap):

#gmap img {
  max-width: none;
}
于 2012-10-04T19:03:23.520 回答