简体   繁体   English

如何在Gmaps4rails 1.5.6中通过ajax更新谷歌地图圈

[英]How to update google map circle through ajax in Gmaps4rails 1.5.6

In my rails application I am using gmaps4rails gem with 1.5.6 version. 在我的rails应用程序中,我使用1.5.6版本的gmaps4rails gem。 I want to update my map circle attributes through ajax 我想通过ajax更新我的地图圈子属性

Can any one please suggest me a procedure to do this? 任何人都可以建议我这样做的程序吗?

First, get your circle, should be in Gmaps.map.circles 首先,得到你的圈子,应该在Gmaps.map.circles

Then: 然后:

 circle.serviceObject.setRadius(number)

In the success function of ajax, you can code like this: 在ajax的成功函数中,您可以这样编码:

 Gmaps.loadMaps()
 // if you are using markers
 markers_json = JSON.parse(markers) 
 Gmaps.map.replaceMarkers(markers_json)
 // if you are using circle
 Gmaps.map.clear_circles() 
 circle_json = JSON.parse(circle)
 Gmaps.map.circles = circle_json
 Gmaps.map.create_circles()

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM