Is it possible to write custom text on Google Maps API v3?

前端 未结 6 513
渐次进展
渐次进展 2020-11-30 01:15

Is it possible to write a custom text on Google Maps API v3 next to the marker, or I can use only the info window to do that?

6条回答
  •  情书的邮戳
    2020-11-30 01:36

    To add custom text to google maps, you can use a marker with an empty pixel for the icon:

    new google.maps.Marker({
        position: { lat: 0, lng: 0 },
        map: map,
        icon: '../res/img/empty.png',
        label: {
            color: '#FF0000',
            fontWeight: 'bold',
            text: 'Hello World',
            fontSize: '20px',
        },
    });
    

    Style options are listed here

提交回复
热议问题