0

How do I put a picture inside a infowindow in my android application running with google maps?

Marker melbourne = mMap.addMarker(new MarkerOptions()
            .position(MELBOURNE)
            .title("Melbourne")
            .snippet("Population: 4'137'400"));

That's how I add some Text but I don't know how to put an image in it. And furthermore, where do I have to save it?

So far, my app works but only without an image.

/Thanks

MrHarrison
  • 15
  • 1
  • 9

1 Answers1

0

You have to inflate layout and then you can put image in infoWindow.

Refer this code:

  googleMap.setInfoWindowAdapter(new InfoWindowAdapter() {
          @Override
            public View getInfoWindow(Marker marker) {

            View v = getApplicationContext().getLayoutInflater().inflate(R.layout.info_window_map_screen_new, null);

             return v;
           };
           @Override
         public View getInfoContents(Marker marker) {
             return null;
         }
    });
Manoj Srivastava
  • 670
  • 5
  • 16
  • and where can I save my images? Please give me a filepath – MrHarrison Jun 20 '17 at 12:15
  • Images are dynamic or static . If images are static then you can place it in drawable and if images are dynamic then you can get it from server , just set the bitmap to image view. – Manoj Srivastava Jun 20 '17 at 12:21
  • If my answer is correct then please mark as correct. Thanks. – Manoj Srivastava Jun 20 '17 at 12:29
  • I'm sorry but the code doesn't work properly. Following Error appears: 'error: cannot find symbol variable conntext, execution failed for task ':app:compileDebugJavaWithJavac'. The 'context.get...' is marked red – MrHarrison Jun 23 '17 at 06:13
  • Ohoo , I am just guide about code. So you have to code for some variables like context = this and other strings. So You can use your layout and in context you can use getApplicationContext() as well. – Manoj Srivastava Jun 23 '17 at 07:17
  • Okay, I'll try in some minutes – MrHarrison Jun 23 '17 at 07:28