- Timestamp:
- 02/17/10 21:43:34 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Products.ATGoogleMaps/trunk/Products/ATGoogleMaps/skins/ATGoogleMaps/gmap.py
r267 r269 2 2 3 3 def add_markers(js, markers): 4 #js.extend(('function addMarker()'))5 4 for marker in markers: 6 5 lat = marker.point['latitude'] 7 6 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)) 22 8 # shape: shape, 23 9 # shadow: shadow, … … 28 14 lng = context.center['longitude'] 29 15 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 )) 35 18 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'])) 45 20 46 # set mavigationControl47 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']))60 21 js.append('}') 61 22
Note: See TracChangeset
for help on using the changeset viewer.
