簡體   English   中英

更改自定義標記形狀Google Maps API

[英]change custom marker shape google maps api

我正在使用Google地圖顯示用戶位置的應用程序,每個用戶都是他的圖片在頁面上的標記。

用戶圖片的形狀為正方形,我想將其更改為圓形而不更改其原始形狀。

有誰知道是否有可能通過谷歌地圖API?

這是我到目前為止所做的: 在此處輸入圖片說明

創建標記的代碼如下:

let userLatLng = {lat: coordinates[0], lng: coordinates[1]};
    let icon = {
        url: Config.s3Address + profileImg,
        origin: new google.maps.Point(0, 0),
        anchor: new google.maps.Point(0, 0),
        scaledSize: new google.maps.Size(50, 50)
    };
    let shape = {
        coords: [0, 0, 60],
        type: 'circle'
    };
    let marker = new google.maps.Marker({
        map: this.map,
        clickable: true,
        animation: google.maps.Animation.DROP,
        position: userLatLng,
        icon: icon,
        shape: shape
    });

    let content = "<h4>" + userName + "</h4>";
    this.addInfoWindow(marker, content);

感謝所有的幫手! :)

用戶圖片大小為50,對不對? 原點在左上角0,所以也許像這樣:

let shape = {
    coords: [25, 25, 25],
    type: 'circle'
};

更多信息在這里

暫無
暫無

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

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