Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google maps marker title not showing up?

I've added a map with a marker to my website but I'm not sure what the Title attribute does for the marker.

I've used the documentation from the developers.google website

https://developers.google.com/maps/documentation/javascript/examples/marker-simple

In this example what does the "hello world" (marker title) exactly do? I am on OS X El Capitan - Chrome

function initMap() {
  var myLatLng = {lat: -25.363, lng: 131.044};

  var map = new google.maps.Map(document.getElementById('map'), {
    zoom: 4,
    center: myLatLng
  });

  var marker = new google.maps.Marker({
    position: myLatLng,
    map: map,
    title: 'Hello World!'
  });
}
like image 920
Frank Lucas Avatar asked Oct 29 '25 11:10

Frank Lucas


1 Answers

User @Vijaykrish93 pointed out, that the title object in the Marker represents the tooltip value.

For labels the documentation has you covered. You just need to set the value for label in Marker:

var marker = new google.maps.Marker({
    position: myLatLng,
    map: map,
    label: "Hello World!"
});

or by using the MarkerLabel interface:

var marker = new google.maps.Marker({
    position: myLatLng,
    map: map,
    label: {
        fontSize: "8pt",
        text: "Hello World!"
    }
});

More formatting options beside fontSize are described here.

like image 198
JackLeEmmerdeur Avatar answered Oct 31 '25 01:10

JackLeEmmerdeur



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!