开发者

Rails, gmaps4rails problem with clusters

Last time I have noticed problem with google maps cluster.

I use gmaps4rails plugin (i tried version 0.8.6 and 1.1.5, and problem exist in both).

Simple map with one marker is displayed properly.

But if i got 10 markers then map isnt showed(many markers create one cluster).

I inspect that problem with firebug and it 开发者_如何转开发return

e.b.mapTypes[e.b.getMapTypeId()] is undefined

This error is from file -> https://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclusterer/1.0/src/markerclusterer_compiled.js

Moreover I tried to disable clustering with options

<%= gmaps({"markers" => { "data" => @json }, "map_options" => {"do_clustering" => false}}, true, true) %>

But I got the same error.

Is there a quick solution to that problem??


This was due to an update from google causing incompatibility.

It's ok now.


Quick solution.

Download this file:

http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclusterer/1.0/src/markerclusterer.js

Put it in:

public/javascripts/markerclusterer.js

And change code at line 90 to

  var maxZoom = 18; //that.map_.mapTypes[that.map_.getMapTypeId()].maxZoom;

Include files in app/views/layouts/applications.html.erb

<%= javascript_include_tag "https://maps.google.com/maps/api/js?sensor=false&libraries=geometry" %>
<%= javascript_include_tag "markerclusterer_compiled.js" %>

and for 0.8.x

 <%= javascript_include_tag "gmaps4rails.js" %>

for 1.x.x

 <%= javascript_include_tag "gmaps4rails.base.js" %>
 <%= javascript_include_tag "gmaps4rails.googlemaps.js" %>

After that you have to use:

 <%= gmaps4rails(@json, true, false) %>

or

 <%= gmaps({ "markers" => { "data" => @json } },true, false) %>

To not download from default location google maps JS files.

Source:

https://github.com/apneadiving/Google-Maps-for-Rails/wiki/View-helper

ClusterMarkerer - no cluster appear - this.map_.mapTypes[this.map_.getMapTypeId()] is undefined markerclusterer.js:304

HTH

Edit Ok Google fixed that problem, but I will leave solution for others.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜