0

I'm making a public transportation map based on Google Maps service for Android. The map should contain a lot of markers (over 300) and they should resize when the map is zooming in and out (scale). Right now the markers just overlap each other, is there a way to create custom markers like this?

example picture

I have tried myself, but have had no success. With android-map-utils library (https://github.com/googlemaps/android-maps-utils) markers now look better, but they aren't resizeable and look different.

Criteria: - Markers contain a dot that points on needed location and text on right or left side of dot - Markers should resize with map.

Trevor Hart
  • 993
  • 7
  • 26
Rincew1nd
  • 196
  • 5
  • 20
  • 1
    Suggestion: You can still use `android-map-utils` and make your own `IconGenerator` class. You will only have to change layout file to your layout file. – Sharjeel May 02 '17 at 04:09
  • This might be help you http://stackoverflow.com/questions/14811579/how-to-create-a-custom-shaped-bitmap-marker-with-android-map-api-v2 – Rajesh N May 02 '17 at 04:16

1 Answers1

1

using bitmapscale

Bitmap markerBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.icon_marker,options);
markerBitmap = SubUtils.scaleBitmap(markerBitmap, 70, 70);

then set it to your Markeroptions

MarkerOptions marker = new MarkerOptions().icon(BitmapDescriptorFactory.fromBitmap(markerBitmap));
Marker mark = googleMap.addMarker(marker);

EDIT

here is scaleBitmap method

public static Bitmap scaleBitmap(Bitmap bitmap, int newWidth, int newHeight) {
        Bitmap scaledBitmap = Bitmap.createBitmap(newWidth, newHeight, Bitmap.Config.ARGB_8888);

        float scaleX = newWidth / (float) bitmap.getWidth();
        float scaleY = newHeight / (float) bitmap.getHeight();
        float pivotX = 0;
        float pivotY = 0;

        Matrix scaleMatrix = new Matrix();
        scaleMatrix.setScale(scaleX, scaleY, pivotX, pivotY);

        Canvas canvas = new Canvas(scaledBitmap);
        canvas.setMatrix(scaleMatrix);
        canvas.drawBitmap(bitmap, 0, 0, new Paint(Paint.FILTER_BITMAP_FLAG));

        return scaledBitmap;
    }
ZeroOne
  • 8,996
  • 4
  • 27
  • 45
  • This answer resolve scale problem. And this answer resolve custom marker problem. http://stackoverflow.com/a/35800880/3089465 – Rincew1nd May 02 '17 at 22:29