简体   繁体   English

圆形Google Maps自定义标记Android

[英]Rounded google maps custom marker android

I want to add a custom marker that looks like this: 我想添加一个如下所示的自定义标记: 内有图像且四舍五入的标记

How can I achieve this? 我该如何实现? I am using Glide and Picasso libraries. 我正在使用Glide和Picasso库。

You can use MarkerOptions 您可以使用MarkerOptions

MarkerOptions markerOptionsObj = new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.Your_Icon));

https://developers.google.com/maps/documentation/android-api/marker https://developers.google.com/maps/documentation/android-api/marker

if you are using Picasso to download/load the pictures, then you can use a Transformation to intercept the bitmap and make it rounded. 如果使用Picasso下载/加载图片,则可以使用Transformation截取位图并将其四舍五入。 The callback gives you the bitmap to transform. 回调为您提供要转换的位图。 You can easily use a BitmapShader with the TileMode.CLAMP to make it round 您可以轻松地使用BitmapShaderTileMode.CLAMP使其圆

要在地图中添加自定义标记,可以使用以下代码行:

MarkerOptions markerOptions = new MarkerOptions().icon(yourBitmap);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM