Search code examples
javascriptgoogle-mapsgoogle-maps-api-3google-maps-markers

How to add text above a marker on Google Maps in JS?


I found exactly the same question for Java, but I'd like to do that in JS. So, how to add text above a marker on Google Maps in JS?


Solution

  • As stated in my comment, You can use multiple letters for the map marker label.

    If you use the label property when instantiating a new google.maps.Marker class, you pass it an object, with one of the properties text.

    var marker = new google.maps.Marker({
        position: new google.maps.LatLng(0, 0),
        icon: 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png',
        label: { color: '#00aaff', fontWeight: 'bold', fontSize: '14px', text: 'Your text here' }
    });
    

    Check the fiddle here.