Jumping markers on Google maps

醉酒当歌 提交于 2019-12-24 07:13:48

问题


I'm building a small site that uses Rails 4 and Gmaps4Rails gem to add a Google Map to the page.

It works quite well except that the markers that are placed on the map based on their geo coded location jump around when I pan or zoom the map. What I mean with this is that the same marker ends up at a slightly different location!

The markers are based on the map's boundary, i.e. I use Geokit to get the markers that are visible on the current map. This process is triggered every time the map becomes idle, i.e. stopped panning or zooming. So, the markers will be replaced - old ones are removed and new ones are added.

My expectation is that the same marker would end up at the same location every time it is added to the map. It does not! Is this a well known "feature" or maybe I have something wrong on my side?

I use Rails 4.0.1 and Gmaps4Rails 2.1.0.

Please let me know what other information I can share in order to find out what I might have done wrong on my side.

Thanks in advance!


回答1:


Its a feature to prevent overlapping. Its documented in the code here.

You can customise or remove the behaviour, example:

handler = Gmaps.build('Google', { markers: { maxRandomDistance: null } });


来源:https://stackoverflow.com/questions/20131387/jumping-markers-on-google-maps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!