On Sat, Dec 10, 2011 at 3:56 AM, skrite <sh...@skrite.net> wrote:

> I am intrigued by this solution, Jim.
> i have a couple of questions, as it seems this is a cleaner way than
> what I am trying to do.
> The values that determine the circle color are in the database, and
> can change while the page is loaded. This is why i need them to
> update.
>

i'll still go with my suggestion earlier.  To update the colors, just update
the sites variable after completing the ajax request and then call
addCircles

your ajax call may look like the following (this is totally untested :D)

$.ajax({
  url: your_url_here_that_returns_json_equivalent_of_@mapped_sites,
  success: function(data) {
    addCircles(data);
  }
});


> So, somehow i still need to go to the server for that. I guess i am
> missing the part about how to get the @mapped_sites variable to the
> controller and back again to the page to rebuild the circles.
> Thanks for your time on this.
> sk
>
> On Dec 9, 9:48 am, Jim Ruther Nill <jvn...@gmail.com> wrote:
> > 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 athttp://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.
>
>


-- 
-------------------------------------------------------------
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