0

I'm developing an app with Android Studio, I'd like to create a RecyclerView where I have an ImageView and upload a static image of a determining point on the map.

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

I tried to use this method with Picasso (Library that takes an image of a url and loads an ImageView) but nothing happens, with other urls of images on the internet that I used to test it worked and loaded in ImageView but with that 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=MY_KEY";

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

Does anyone know how to do this? With this or another method?

I have tried the methods in other posts reporting this problem but my url is correct in relation to the others.

Zoe
  • 27,060
  • 21
  • 118
  • 148
  • The question is does this url really point to a static image? Have you tried to download the image with the url in a web browser? – Barns Dec 21 '18 at 18:06
  • @Barns Yes, I tested the URL in the browser with my key. It generates the image normally. Downloading it would not help, as I need to generate the images by moving latitude and longitude dynamically. –  Dec 21 '18 at 18:09
  • That wasn't my point that you should use the browser to download the image and save it. I just wanted to know if you had verified that the url points to an actual image. – Barns Dec 21 '18 at 18:12
  • @Barns Generates a png image –  Dec 21 '18 at 18:13
  • @C.Oli did you find a solution to this? – eyes enberg Jan 05 '19 at 15:42
  • @eyesenberg I didn't :( –  Jan 07 '19 at 17:38
  • 1
    @C.Oli I fixed mine by using the correct API key (turns out I was using a key that wasn't for Android so it worked on my browser but not on the application). I left some suggestions for you, maybe they'll help – eyes enberg Jan 11 '19 at 19:44

2 Answers2

0

Make sure you're using the right API key (use the one specifically for Android) and get a more detailed stacktrace by adding a simple success/error callback: Android: Picasso load image failed . how to show error message

eyes enberg
  • 556
  • 1
  • 8
  • 30
0

You need to enable the billing option in your project. Google change the payment methods and now you need to enable this option in order to use some APIs.