Ignore:
Timestamp:
02/17/10 21:43:34 (2 years ago)
Author:
takanori
Message:

use create map and marker function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Products.ATGoogleMaps/trunk/Products/ATGoogleMaps/skins/ATGoogleMaps/gmap.py

    r267 r269  
    22 
    33def add_markers(js, markers): 
    4     #js.extend(('function addMarker()')) 
    54    for marker in markers: 
    65        lat = marker.point['latitude'] 
    76        lng = marker.point['longitude'] 
    8         js.extend(('  var marker_%s = new google.maps.Marker({' % marker.id, 
    9                    '    position: new google.maps.LatLng(%s, %s),' % (lat, lng), 
    10                    '    map: map,', 
    11                    '    title: "%s"' % unicode(marker.Title(), site_encoding), 
    12 #                   '    icon: image', 
    13                    '  });', 
    14                    )) 
    15         js.extend(('  var infowindow_%s = new google.maps.InfoWindow({' % marker.id, 
    16                    '    content: "<h2>%s</h2>"' % unicode(marker.Title(), site_encoding), 
    17                    '  });', 
    18                    "  google.maps.event.addListener(marker_%s, 'click', function() {" % marker.id, 
    19                    '    infowindow_%s.open(map, marker_%s)' % (marker.id, marker.id), 
    20                    '  });', 
    21                    )) 
     7        js.append('  var marker_%s = createMarker(map, %s, %s, "%s");' % (marker.id, lat, lng, marker.title)) 
    228#      shape: shape, 
    239#      shadow: shadow, 
     
    2814    lng = context.center['longitude'] 
    2915    js.extend(('function initialize() {', 
    30                '  var myOptions = {', 
    31                '    zoom: %s,' % context.zoom, 
    32                '    center: new google.maps.LatLng(%s, %s),' % (lat, lng), 
    33                '    mapTypeId: google.maps.MapTypeId.%s,' % context.mapType, 
    34                )) 
     16               '  var map = createMap("map_canvas", %s, %s, %s, "%s", "%s", "%s");' % (lat, lng, context.zoom, context.mapType, context.mapTypeControl, context.navigationControl), 
     17               )) 
    3518 
    36     # set mapTypeControl 
    37     if context.mapTypeControl == "nothing": 
    38         js.append('    mapTypeControl: false,') 
    39     else: 
    40         js.extend(('    mapTypeControl: true,', 
    41                    '    mapTypeControlOptions: {', 
    42                    '      style: google.maps.MapTypeControlStyle.%s,' % context.mapTypeControl, 
    43                    '    },', 
    44                    )) 
     19    add_markers(js, context.objectValues(['GMarker'])) 
    4520 
    46     # set mavigationControl 
    47     if context.navigationControl == "nothing": 
    48         js.append('    navigationControl: false,') 
    49     else: 
    50         js.extend(('    navigationControl: true,', 
    51                    '    navigationControlOptions: {', 
    52                    '      style: google.maps.NavigationControlStyle.%s' % context.navigationControl, 
    53                    '    },', 
    54                    )) 
    55  
    56     js.extend(('  };', 
    57                '  var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);', 
    58                )) 
    59     add_markers(js, context.objectValues(['GMarker'])) 
    6021    js.append('}') 
    6122     
Note: See TracChangeset for help on using the changeset viewer.