Jumping markers on Google maps

2019-08-12 04:44发布

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条回答
Deceive 欺骗
2楼-- · 2019-08-12 05:25

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 } });
查看更多
登录 后发表回答