On Fri, Dec 9, 2011 at 11:04 PM, skrite <sh...@skrite.net> wrote:

> Hey, thanks for these links, very helpful.
> -sk
>
> On Dec 8, 7:49 pm, "L.Karthikeyan" <logkart...@gmail.com> wrote:
> > Hi,
> >
> >       For this you need to use rjs Ajax request. Please refer the
> > following links, you will get an idea.
> >
> > 1.http://railscasts.com/episodes/43-ajax-with-rjs?autoplay=true,
> > 2.http://railscasts.com/episodes/229-polling-for-changes?autoplay=true
> >
>

one more option is to keep @mapped_sites to a javascript variable so you
dont have to use ajax.  you might also want to move the makeMarker part
to a js function to tidy up the view and just call that function when you
need
to update the colors

something along the lines of

var sites = <%= @mapped_sites.to_json %>;
addCircles(sites);

function addCircles(circles) {
  for(i=0; i<circles.length; i++) {
    center = new google.maps.LatLng(circles[i][0], circles[i][1]);
    siteCircle = makeMarker({
      position: center,
      strokeColor: "#FF0000",
      strokeOpacity: 0.8,
      strokeWeight: 2,
      fillColor: circles[i][7],
      fillOpacity: 0.75,
      radius: 560,
      map: map,
      center: center,
      radius: circles[i][2],
      title: circles[i][5],
      content: 'content'
    });
  }
}

then you just need to update the sites variable using js. no need
to go back to the server.



> >
> >
> >
> >
> >
> >
> >
> >
> > On Thu, Dec 8, 2011 at 1:10 AM, skrite <sh...@skrite.net> wrote:
> >
> > > Hey all,
> > > i have a google map and i am drawing circles on the map like this..
> >
> > >  var latlng = new google.maps.LatLng(35.931387,
> > > -102.31062);
> > >    var myMapOptions =
> > > {
> > >      zoom:
> > > 12,
> > >      center:
> > > latlng,
> > >      mapTypeId:
> > > google.maps.MapTypeId.HYBRID
> > >    };
> >
> > >    var map = new
> > > google.maps.Map(document.getElementById("map_canvas"),
> > > myMapOptions);
> > >    var infoWindow = new
> > > google.maps.InfoWindow();
> > >    var markerBounds = new
> > > google.maps.LatLngBounds();
> >
> > >   <% @mapped_sites.each do |row|
> > > %>
> >
> > >        // main
> > > circle
> > >        center = new google.maps.LatLng(<%= "#{row[0]}" %>, <%=
> > > "#{row[1]}"
> > > %>);
> > >        siteCircle =
> > > makeMarker({
> > >          position:
> > > center,
> > >          strokeColor:
> > > "#FF0000",
> > >          strokeOpacity:
> > > 0.8,
> > >          strokeWeight:
> > > 2,
> > >          fillColor: '<%= "#{row[7]}"
> > > %>',
> > >          fillOpacity:
> > > 0.75,
> > >          radius:
> > > 560,
> > >          map:
> > > map,
> > >          center:
> > > center,
> > >          radius: <%= "#{row[2]}"
> > > %>,
> > >          title: '<%= "#{row[5]}"
> > > %>',
> > >          content: '<%= "some contnet
> > > %>'
> > >       });
> >
> > >       markerArray.push(siteCircle);
> >
> > > my question is, that since the fillColor is going to change from time
> > > to time, i want to update all the colors of the circles periodically.
> > > What i don't know how to do is get the equivelent to the
> > > @mapped_sites  because if i could, i think i could just delete the
> > > existing circles and draw new ones.
> >
> > > How do i get info back from the server periodically to update the
> > > circle colors?
> >
> > > thanks to all.
> > > skrite
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups "Ruby on Rails: Talk" group.
> > > To post to this group, send email to rubyonrails-talk@googlegroups.com
> .
> > > To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> > > For more options, visit this group athttp://
> groups.google.com/group/rubyonrails-talk?hl=en.
> >
> > --
> >
> > Regards,
> > L.KarthiKeyan.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>


-- 
-------------------------------------------------------------
visit my blog at http://jimlabs.heroku.com

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to