how can I display a static map in my view from such a url: http://maps.google.com/staticmap?center=40.714728,-73.998672&zoom=14&size=512x512&maptype=mobile&markers=40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc&key=MAPS_API_KEY -- Posted via http://www.ruby-forum.com/.
> how can I display a static map in my view from such a url: > http://maps.google.com/staticmap?center=40.714728,-73.998672&zoom=14&size=512x512&maptype=mobile&markers=40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc&key=MAPS_API_KEYhttp://www.google.com/search?q=google+map+static+api First result.
> http://www.google.com/search?q=google+map+static+api > > First result.I know. But how should I render that? A simple <%= image_tag(that_url) %> is not possible... -- Posted via http://www.ruby-forum.com/.
Zoran Surname wrote: [...]> I know. But how should I render that? A simple <%= image_tag(that_url) > %> is not possible...So use literal HTML rather than image_tag. Remember, there''s nothing magical about helpers! Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
use iframe ~N A R E N On Tue, Jun 16, 2009 at 2:46 PM, Marnen Laibow-Koser < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Zoran Surname wrote: > [...] > > I know. But how should I render that? A simple <%= image_tag(that_url) > > %> is not possible... > > So use literal HTML rather than image_tag. Remember, there''s nothing > magical about helpers! > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > Posted via http://www.ruby-forum.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Narendra sisodiya wrote:> use iframeBad idea. There''s no need to use an iframe to display a single image!> > ~N A R E NBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
Marnen Laibow-Koser wrote:> Zoran Surname wrote: > [...] >> I know. But how should I render that? A simple <%= image_tag(that_url) >> %> is not possible... > > So use literal HTML rather than image_tag. Remember, there''s nothing > magical about helpers! > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.orgI''ve already tried that but got same result... -- Posted via http://www.ruby-forum.com/.
> I''ve already tried that but got same result...So what was the result? Try it again, and look at the source for your web page for that image. That should let you see what is really and truly getting rendered by your code. From there, you should be able to see that the API call is correctly formed. -- Posted via http://www.ruby-forum.com/.
Ar Chron wrote:>> I''ve already tried that but got same result... > > So what was the result? > > Try it again, and look at the source for your web page for that image. > That should let you see what is really and truly getting rendered by > your code. From there, you should be able to see that the API call is > correctly formed.This is the HTML result: <img alt="Staticmap?center=40" src="http://maps.google.com/staticmap?center=40.714728,-73.998672&zoom=14&size=512x512&maptype=mobile&markers=40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc&key=MAPS_API_KEY" /> I also tried things like: static_map = Net::HTTP.get_response(URI.parse(map_url)) @static_map = Magick::Image::from_blob(static_map.body.read).first <%= @static_map %> then shows me a blob: "GIF89a� � ���...." static_map_url = "http://maps.google.com/staticmap?center=40.714728,-73.998672&zoom=14&size=512x512&maptype=mobile&markers=40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc&key=MAPS_API_KEY" static_map = open(static_map_url) { |f| @static_map = Magick::Image::from_blob(f.read).first } In the console I get then => GIF 512x512 512x512+0+0 PseudoClass 256c 8-bit 77kb @static_map.rows => 512 The image is there but I don''t know how to render this one. -- Posted via http://www.ruby-forum.com/.
Well, the img tag works! But only if it''s not in a partial. Why is that? -- Posted via http://www.ruby-forum.com/.
Forgot to mention: it''s a parial which is called by <% content_for(:x) do %> <%= render :partial => ''y'' %> <% end %> -- Posted via http://www.ruby-forum.com/.
2009/6/17 Zoran Surname <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > Ar Chron wrote: >>> I''ve already tried that but got same result... >> >> So what was the result? >> >> Try it again, and look at the source for your web page for that image. >> That should let you see what is really and truly getting rendered by >> your code. From there, you should be able to see that the API call is >> correctly formed. > > > This is the HTML result: > > <img alt="Staticmap?center=40" > src="http://maps.google.com/staticmap?center=40.714728,-73.998672&zoom=14&size=512x512&maptype=mobile&markers=40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc&key=MAPS_API_KEY" > /> >That link does not work, past it into browser and see. I guess it is due to the & in there.> I also tried things like: > static_map = Net::HTTP.get_response(URI.parse(map_url)) > @static_map = Magick::Image::from_blob(static_map.body.read).first > > <%= @static_map %> then shows me a blob: > "GIF89a� � ���...." > > > > static_map_url > "http://maps.google.com/staticmap?center=40.714728,-73.998672&zoom=14&size=512x512&maptype=mobile&markers=40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc&key=MAPS_API_KEY"That link does work. Colin> static_map = open(static_map_url) { |f| > @static_map = Magick::Image::from_blob(f.read).first > } > > In the console I get then > => GIF 512x512 512x512+0+0 PseudoClass 256c 8-bit 77kb > @static_map.rows > => 512 > > The image is there but I don''t know how to render this one. > -- > Posted via http://www.ruby-forum.com/. > > > >
The link (with & in img tag) works, but as I mentioned before only if the img tag is not in a partial called by <% content_for(:x) do %> <%= render :partial => ''y'' %> <% end %> -- Posted via http://www.ruby-forum.com/.
2009/6/17 Zoran Surname <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > The link (with & in img tag) works, but as I mentioned before only > if the img tag is not in a partial called by > > <% content_for(:x) do %> > <%= render :partial => ''y'' %> > <% end %> > --Well I just pasted http://maps.google.com/staticmap?center=40.714728,-73.998672&zoom=14&size=512x512&maptype=mobile&markers=40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc&key=MAPS_API_KEY into FF and it didn''t work. (404 not found) Colin> Posted via http://www.ruby-forum.com/. > > > >
Colin Law wrote:> 2009/6/17 Zoran Surname <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>: >> >> The link (with & in img tag) works, but as I mentioned before only >> if the img tag is not in a partial called by >> >> <% content_for(:x) do %> >> <%= render :partial => ''y'' %> >> <% end %> >> -- > > Well I just pasted > http://maps.google.com/staticmap?center=40.714728,-73.998672&zoom=14&size=512x512&maptype=mobile&markers=40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc&key=MAPS_API_KEY > into FF and it didn''t work. (404 not found) > > ColinYes, in a browser. But try that in img tag and you will see it works. -- Posted via http://www.ruby-forum.com/.
2009/6/17 Zoran Surname <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > Colin Law wrote: >> 2009/6/17 Zoran Surname <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>: >>> >>> The link (with & in img tag) works, but as I mentioned before only >>> if the img tag is not in a partial called by >>> >>> <% content_for(:x) do %> >>> <%= render :partial => ''y'' %> >>> <% end %> >>> -- >> >> Well I just pasted >> http://maps.google.com/staticmap?center=40.714728,-73.998672&zoom=14&size=512x512&maptype=mobile&markers=40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc&key=MAPS_API_KEY >> into FF and it didn''t work. (404 not found) >> >> Colin > > Yes, in a browser. But try that in img tag and you will see it works.True, I should have paid more attention to what you wrote. So if I understand correctly you are saying the the html <img alt="Staticmap?center=40" src="http://maps.google.com/staticmap?center=40.714728,-73.998672&zoom=14&size=512x512&maptype=mobile&markers=40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc&key=MAPS_API_KEY" /> works sometimes but not if generated by a partial? If so then I would suggest it is something to do with the html around the img tag rather than the tag itself. Have you tried pasting the complete page source into the html validator at http://validator.w3.org/#validate_by_input Colin
I tried that in a new empty document. Not the partial by itself causes is the problem but the <% content_for(:x) do %> containing the partial. The result is a valid html image tag and the src url is correct but the image is curiously not displayed. -- Posted via http://www.ruby-forum.com/.
2009/6/17 Zoran Surname <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > I tried that in a new empty document. Not the partial by itself causes > is the problem but the <% content_for(:x) do %> containing the partial. > The result is a valid html image tag and the src url is correct but the > image is curiously not displayed. > --I believe that the browser cannot tell how the the html was generated, it just interprets the html. Can you remove as much as possible from the page that does not work and post the complete (html) source? Colin