Google Marker群集在哪里?

时间:2016-05-21 01:19:01

标签: javascript ruby-on-rails google-maps google-maps-api-3 gmaps4rails

在适应从谷歌到Git的新动向之后,一个问题仍然存在。

  

http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/images/m1.png无法加载资源:服务器响应状态为404(未找到)

我该怎么做才能在地图上渲染标记聚类,而不是?

我正在使用咖啡脚本:

class RichMarkerBuilder extends Gmaps.Google.Builders.Marker #inherit from builtin builder
  #override create_marker method
  create_marker: ->
    options = _.extend @marker_options(), @rich_marker_options()
    @serviceObject = new RichMarker options #assign marker to @serviceObject

  rich_marker_options: ->
    marker = document.createElement("div")
    marker.setAttribute 'class', 'marker_container'
    marker.innerHTML = @args.title
    _.extend(@marker_options(), { content: marker })

  infobox: (boxText)->
    content: boxText
    pixelOffset: new google.maps.Size(-140, 0)
    boxStyle:
      width: "300px"

  # override method
  create_infowindow: ->
    return null unless _.isString @args.infowindow
    boxText = document.createElement("div")
    boxText.setAttribute("class", 'marker_info_box') #to customize
    boxText.innerHTML = @args.infowindow
    @infowindow = new InfoBox(@infobox(boxText))

@buildMap = (markers)->
    handler = Gmaps.build 'Google', { builders: { Marker: RichMarkerBuilder} } #dependency injection

    #then standard use
    handler.buildMap { provider: {}, internal: {id: 'map'} }, ->
      markers = handler.addMarkers(markers)
      handler.bounds.extendWith(markers)
      handler.fitMapToBounds()

1 个答案:

答案 0 :(得分:2)

  1. 下载此图片并将其包含在您的项目中:https://cdn.rawgit.com/googlemaps/js-marker-clusterer/gh-pages/images/m1.png

  2. 搜索(大多数IDE上的CTRL + SHIFT + F,取决于您使用的IDE /平台)整个项目,包括此字符串的库" http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/images/m1.png"

  3. 将找到的匹配项替换为下载图像的链接。

  4. (请不要直接从https://cdn.rawgit.com引用图片...因为以后网址可能会再次发生变化,就像几周前一样,你会遇到同样的问题。只需下载它在你的项目的图像文件之间并从那里引用它)