簡體   English   中英

如何在Android中使用用戶圖像設置Google Maps標記?

[英]How to set a google maps marker with user image in android?

我正在實現一個GPS跟蹤應用程序。在該應用程序中,我需要設置一個Google地圖標記,並在標記中屏蔽特定的用戶圖像。

隨附的是帶有用戶個人資料圖像的標記的示例。 我想實現類似的目標

像這樣

提前致謝

您可以使用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)

可以將Google標記設置為圖像。 您可以在github中找到具有Google標記作為圖像的類似項目。 鏈接是輸入鏈接描述在這里

在此鏈接中,“聚類自定義外觀”是針對Google標記的圖像。

請參考下面的演示,將自定義標記作為個人資料圖片。

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

在這里,您可以根據需要替換蒙版圖像作為大頭針標記,並且可以對圓形圖像使用RoundedBitmapDrawable。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM