Ignore:
Timestamp:
03/04/10 03:54:44 (2 years ago)
Author:
takanori
Message:

use createMap(), createMarker() function

File:
1 edited

Legend:

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

    r285 r287  
    3333var visibleInfoWindow = null; 
    3434 
    35 function createMarker(map, lat, lng, marker_id, title) { 
     35function createMarker(map, lat, lng, marker_id, title, draggable) { 
    3636    var shape = { 
    3737        coord: <dtml-var "gmap_properties.icon_shape">, 
     
    5151    </dtml-with> 
    5252 
     53    if (draggable == null) { 
     54        draggable = false; 
     55    } 
    5356    var marker = new google.maps.Marker({ 
    5457        position: new google.maps.LatLng(lat, lng), 
     
    5760        icon: icon, 
    5861        shadow: shadow, 
    59         shape: shape 
     62        shape: shape, 
     63        draggable: draggable 
    6064    }); 
    6165 
    62     var content = document.getElementById('infowindow_html_' + marker_id).innerHTML; 
    63     var infoWindow = new google.maps.InfoWindow({ 
    64         content: content 
    65     }); 
     66    if (marker_id) { 
     67        var content = document.getElementById('infowindow_html_' + marker_id).innerHTML; 
     68        var infoWindow = new google.maps.InfoWindow({ 
     69            content: content 
     70        }); 
     71        google.maps.event.addListener(marker, 'click', function() { 
     72            if (visibleInfoWindow) { 
     73                visibleInfoWindow.close(); 
     74            } 
     75            infoWindow.open(map, marker); 
     76            visibleInfoWindow = infoWindow; 
     77        }); 
    6678 
    67     google.maps.event.addListener(marker, 'click', function() { 
    68         if (visibleInfoWindow) { 
    69             visibleInfoWindow.close(); 
    70         } 
    71         infoWindow.open(map, marker); 
    72         visibleInfoWindow = infoWindow; 
    73     }); 
    74  
    75     var link = document.getElementById("infowindow_link_" + marker_id); 
    76     link.onclick = function() { 
    77         google.maps.event.trigger(marker, "click"); 
    78     }; 
     79        var link = document.getElementById("infowindow_link_" + marker_id); 
     80        link.onclick = function() { 
     81            google.maps.event.trigger(marker, "click"); 
     82        }; 
     83    } 
    7984 
    8085    return marker; 
Note: See TracChangeset for help on using the changeset viewer.