如何在Android中设置带有用户图像的谷歌地图标记?

时间:2015-06-05 07:36:04

标签: android google-maps google-maps-markers android-drawable

我正在实施GPS跟踪应用程序。在该应用程序中,我需要设置一个谷歌地图标记,并在标记中屏蔽特定的用户图像。

附件是带有用户个人资料图片的标记示例。我想实现类似的东西

Like This

先谢谢

3 个答案:

答案 0 :(得分:0)

您可以使用BitmapDescriptorFactory加载和创建自定义标记图标:

new MarkerOptions()
    .position(latlng)
    .icon(BitmapDescriptorFactory.fromResource(resId))

BitmapDescriptorFactory声明:

public static BitmapDescriptor fromResource(int resourceId)
public static BitmapDescriptor fromAsset(String assetName)
public static BitmapDescriptor fromFile(String fileName) 
public static BitmapDescriptor fromPath(String absolutePath)
public static BitmapDescriptor fromBitmap(Bitmap image)

答案 1 :(得分:0)

可以将Google标记设置为图像。您可以在github中找到具有Google标记作为图像的类似项目。 链接是enter link description here

在此链接中,“群集自定义外观”用于将Google标记为图像。

答案 2 :(得分:0)

请参阅以下演示,了解自定义标记作为个人资料图片。

http://waleedsarwar.com/posts/2016-03-03-custom-markers-google-maps/

在这里,您可以根据需要将遮罩图像替换为图钉标记,并且可以使用RoundedBitmapDrawable作为圆角图像。