Search code examples
androidpicasso

Picasso won't load Google Static Map


I'm trying to load an static map using this url:

http://maps.googleapis.com/maps/api/staticmap?center=43.137022,13.067162&zoom=16&size=600x400&maptype=roadmap&sensor=true&markers=color:blue|43.137022,13.067162

I'm doing it with Square's Picasso, but it fails to load.

With some tests I've to the conclusion that the char | is the one messing up Picasso. Any idea on how to overcome this issue?


Solution

  • Picasso appears to expect a URL-encoded URL. This means that the values of form variables need to be URL-encoded, the way they would if this were a submitted HTML form.

    Alphanumeric characters do not need escaping, which is why most of your URL is fine. However, the markers parameter contains special characters, particularly that |, which need to be converted into URL-encoded values.

    If you were programmatically generating the URL by pieces, you might use URLEncoder and encode() to handle this conversion for you.