0

I have a icon image in drawable folder and i set it to map marker icon but i need to set an image to on above the existing marker click to See the white portion of the image(1st) on where i want to show an image (2nd) this image to be shown on that previous white portion of that 1st image.

*The first image is a custom marker which is static and i get it from the drawable folder.

*The second one is a simple image which i get from web service url.**

LatLng userPosition = new LatLng(
                    Double.parseDouble(item.latitude),
                    Double.parseDouble(item.longitude));
                googleMap.addMarker(new MarkerOptions()
                    .position(userPosition)
                    .title(item.vendorname)
                    .snippet("Service : " + item.category_name)
                    .icon(BitmapDescriptorFactory.fromResource(R.drawable.location_pin))

These above codes are for view the marker icon on the map.But i need to show an another image above it.So i get the url via web service like this(below code).

try {   
     URL url = new URL(CommonUtilities.Thumb_Call+ item.vendor_icon);
     bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
      bmp = BitmapFactory.decodeFile(String.valueOf(url));
     } 
     catch (Exception e) 
      {
         e.printStackTrace();
    }

Please help me to set the image on above the marker which is coming from the url.

Sudhansu
  • 780
  • 1
  • 9
  • 28
  • hey follow the below link it may give you some idea- [Customize marker icon](http://stackoverflow.com/questions/10077494/android-custom-marker-icon) – sud Oct 28 '15 at 10:35
  • i know how to set the marker but dont know how to set an another image above it – Sudhansu Oct 28 '15 at 10:37
  • you can add second image on first image with picture editing tool... this is the only way i can see. non programaticaly its possible, programaticaly i dont think so – sud Oct 28 '15 at 10:38
  • Do you know any kind of editing tool @sud?? – Sudhansu Oct 28 '15 at 11:12
  • there are number of online photo editing tools on google. just google 'online photo editor' – sud Oct 28 '15 at 11:16
  • @sud let me explain you clearly first see the second image which I am trying to set on 1st image is coming from web service it is not a static one. I am getting it from web service and set it on marker – Sudhansu Oct 28 '15 at 11:29

1 Answers1

0

This problem can be resolved as follows:

firstly create custom_marker_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<ImageView
    android:id="@+id/imageView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:srcCompat="@drawable/markertoemp"
    tools:ignore="VectorDrawableCompat" />

<ImageView
    android:id="@+id/inside"
    android:layout_width="32.25dp"
    android:layout_height="32.25dp"
    android:layout_centerInParent="true"
    android:layout_marginBottom="22dp"
    android:layout_marginEnd="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    app:layout_constraintBottom_toBottomOf="@+id/imageView4"
    app:layout_constraintEnd_toEndOf="@+id/imageView4"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="@+id/imageView4"
    app:srcCompat="@drawable/ic_delevery_primary"
    tools:ignore="MissingConstraints,VectorDrawableCompat" />

</android.support.constraint.ConstraintLayout>

now go to java and put this method:

    private void setUpMap(final EmpMarker emp) {
    LatLng empLatLog = new LatLng(emp.getLatitude(), emp.getLongitude());

    View marker = ((LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.lyout.custom_marker_layout, null);
    ImageView imageView = marker.findViewById(R.id.inside);
    GlideApp.with(activity).load(URLs.Glide_URL + imgeSub).apply(RequestOptions.circleCropTransform()).into(imageView);

    new Handler().postDelayed(() -> {
        customMarker = mMap.addMarker(new MarkerOptions()
                .position(empLatLog)
                .icon(BitmapDescriptorFactory.fromBitmap(createDrawableFromView(marker))));
        customMarker.setTag(emp);
    }, 10);
 }

Good luck :)