Ignore:
Timestamp:
02/20/10 16:14:25 (2 years ago)
Author:
takanori
Message:

add marker, link click behavior

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Products.ATGoogleMaps/trunk/Products/ATGoogleMaps/skins/ATGoogleMaps/atgooglemaps.js.dtml

    r269 r272  
    3131} 
    3232 
    33 function createMarker(map, lat, lng, title) { 
     33var visibleInfoWindow = null; 
     34 
     35function createMarker(map, lat, lng, marker_id, title) { 
    3436    var marker = new google.maps.Marker({ 
    3537        position: new google.maps.LatLng(lat, lng), 
     
    3840    }); 
    3941 
    40     var infowindow = new google.maps.InfoWindow({ 
    41         content: "<div>" + title + "</div>" 
     42    var content = document.getElementById('infowindow_html_' + marker_id).innerHTML; 
     43    var infoWindow = new google.maps.InfoWindow({ 
     44        content: content 
    4245    }); 
    4346 
    4447    google.maps.event.addListener(marker, 'click', function() { 
    45         infowindow.open(map, marker); 
     48        if (visibleInfoWindow) { 
     49            visibleInfoWindow.close(); 
     50        } 
     51        infoWindow.open(map, marker); 
     52        visibleInfoWindow = infoWindow; 
    4653    }); 
     54 
     55    var link = document.getElementById("infowindow_link_" + marker_id); 
     56    link.onclick = function() { 
     57        google.maps.event.trigger(marker, "click"); 
     58    }; 
     59 
    4760    return marker; 
    4861} 
Note: See TracChangeset for help on using the changeset viewer.