Display static map Google with Picasso on Android

Asked

Viewed 89 times

0

I am developing an app by Android Studio, I would like to create a Recyclerview where you have an Imageview and upload a static image of a determining point on the map.

As here: https://developers.google.com/maps/documentation/maps-static/intro

I tried using this method with Picasso (Library that takes an image of a url and loads an Imageview) but nothing happens, with other image urls on the Internet that I used to test it worked and loaded in Imageview but with this nothing appears:

imageMap = findViewById(R.id.imageMap);

        String lat = "-12.958811";
        String lon = "-38.401606";

        String url ="https://maps.googleapis.com/maps/api/staticmap?";
        url+="&zoom=14";
        url+="&size=330x130";
        url+="&maptype=roadmap";
        url+="&markers=color:green%7Clabel:G%7C"+lat+", "+lon;
        url+="&key=AQUI_VEM_A_MINHA_KEY";

        Picasso.get().load(url).into(imageMap);

Does anyone know how to do this, with this or another method?

  • Your idea is good! I don’t understand why it doesn’t work... URL parameters are correct?

  • @Andreicoelho Yes, but if you put the link in the browser you can see that it does not load the image in the same way

  • Here image loaded normally. Your key is valid?

  • Remember, you need to activate the api Maps Static API

  • @Lmaker I activated Maps Static API yes, the key is valid for Android device, I use it to display the full map in my app and works normally

  • @Lmaker Ok, I finally managed to load the map in the browser, actually the API was enabled but n was associated with that key. But it does not load in the App by Picasso, tested with the url of other common images and uploaded good :(

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.