开发者

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 m开发者_运维百科arker = 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");


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

marker.setTitle(name);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜