Snake
Snake

Reputation: 14658

Vector graphics used for google map marker

Is there a way to use vector graphics to be google maps marker? I know that google maps takes a bitmap for a marker, but I have a vector graphics (coming from server) and I am not sure how to display that as marker?

Thank you

Upvotes: 5

Views: 2361

Answers (2)

BladeCoder
BladeCoder

Reputation: 12929

Technically, if you are able to render your vector image as a Drawable, you can use it as a map marker. Vector drawables on Android are complicated but maybe you already solved that problem.

You need to programmatically create a writable Bitmap with the desired size (specify your constant size in dips to adjust it to the screen density), create a Canvas based on that Bitmap, set the bounds on your Drawable then draw it on the Canvas. Your Bitmap will then contain the rendering of your Drawable and you can create a Marker from it.

Upvotes: 1

Marcin Orlowski
Marcin Orlowski

Reputation: 75629

but I have a vector graphics file and I am not sure how to achieve that?

Open it in your vector drawing app and export as bitmap (PNG) to use on Android. This is the less painful way than anything else.

Upvotes: 0

Related Questions