简体   繁体   中英

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. I want to update my map circle attributes through ajax

Can any one please suggest me a procedure to do this?

First, get your circle, should be in Gmaps.map.circles

Then:

 circle.serviceObject.setRadius(number)

In the success function of ajax, you can code like this:

 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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