简体   繁体   English

更改自定义标记形状Google Maps API

[英]change custom marker shape google maps api

I'm working on an app that uses google maps to show users location, each user is a marker on the page with his picture. 我正在使用Google地图显示用户位置的应用程序,每个用户都是他的图片在页面上的标记。

The user picture shape is square and I want to change it to circle without changing its original shape. 用户图片的形状为正方形,我想将其更改为圆形而不更改其原始形状。

does anyone know if its possible through google maps API? 有谁知道是否有可能通过谷歌地图API?

here is what I made so far: 这是我到目前为止所做的: 在此处输入图片说明

The code that's creating the marker is the following: 创建标记的代码如下:

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);

Thanks for all the helpers !! 感谢所有的帮手! :) :)

The user picture size is 50, right? 用户图片大小为50,对不对? the origin point is left top 0, so maybe like this: 原点在左上角0,所以也许像这样:

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

More info here . 更多信息在这里

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

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