Add URL Image to the Marker in Google Map

Updated 9 June 2018

Save

In this blog, you know how to add URL image marker in Google Map.

It is a tough task to add URL Image to Marker. I use Picasso Library to parse image, for getting more about Picasso library see my other blog. Before knowing to add a marker in Map. You should check In your Manifest file having google map API.

How to add?

Display a map, using the Maps SDK for Android.

  1. Add an<fragment> element to your activity’s layout file,activity_maps.xml This element defines aSupportMapFragment to act as a container for the map and to provide access to the objectGoogleMap. The tutorial uses the Android support library version of the map fragment, to ensure backward compatibility with earlier versions of the Android framework.

2. In your activity’s methodonCreate(), set the layout file as the content view. Get a handle to the map fragment by calling.FragmentManager.findFragmentById() Then use getMapAsync() to register for the map callback:

3. Implement the OnMapReadyCallback interface and override the onMapReady() method, to set up the map when the GoogleMap object is available:

Now I am describing, how to URL image load with Marker. Create a CustomTarget class that implement Target Interface, and load the bitmap to Marker via BitmapDescriptorFactory. The main issue comes when we add multiple Markers and load maker image from URL  because of Picasso load image take some time rapidly we add a marker in a loop so some marker is not displayed. How you fix that issue, you create multiple Target object instance and add them to the List for each Marker.

For more About Picasso.

Picasso Library Use for Image Loading in Android

References: https://developers.google.com/maps/documentation/android-sdk/map-with-marker

 

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


2 comments

  • Mr. Baks
    • ashwini gupta (Moderator)
  • Start a Project


      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home