RonnieT
RonnieT

Reputation: 2203

Google Map Marker Tooltip

How do I get the default tooltip title: 'Testing' of each marker to update via the XML data that I am parsing down in the script from this?

function createMarker(latlng, name, html) {
var contentString = html;
var marker = new google.maps.Marker({
    position: latlng,
    title: 'Testing',
    icon: 'images/test.png' ,
    map: map,
    zIndex: Math.round(latlng.lat()*-100000)<<5
    });

Loading XML (want to pull from var name):

downloadUrl("data.xml", function(doc) {
    var xmlDoc = xmlParse(doc);
    var markers = xmlDoc.documentElement.getElementsByTagName("marker");
    for (var i = 0; i < markers.length; i++) {
      // obtain the attribues of each marker
      var lat = parseFloat(markers[i].getAttribute("lat"));
      var lng = parseFloat(markers[i].getAttribute("lng"));
      var point = new google.maps.LatLng(lat,lng);
      var name = markers[i].getAttribute("name");

Upvotes: 0

Views: 3945

Answers (1)

Trott
Trott

Reputation: 70055

You can update the title text of a marker with the setTitle() method:

marker.setTitle(name);

Upvotes: 2

Related Questions