Changeset 269
- Timestamp:
- 02/17/10 21:43:34 (2 years ago)
- Location:
- Products.ATGoogleMaps/trunk/Products/ATGoogleMaps/skins/ATGoogleMaps
- Files:
-
- 2 edited
-
atgooglemaps.js.dtml (modified) (2 diffs)
-
gmap.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Products.ATGoogleMaps/trunk/Products/ATGoogleMaps/skins/ATGoogleMaps/atgooglemaps.js.dtml
r233 r269 1 function createMap(map_id, lat, lng, zoom, map, type, scale, overview, map_type) { 2 if(lat == undefined) { 3 lat = 0.0; 4 } 5 if(lng == undefined) { 6 lng = 0.0; 7 } 8 if(zoom == undefined) { 9 zoom = 0; 10 } 11 if(map == undefined) { 12 map = 'small'; 13 } 14 if(type == undefined) { 15 type = 'small'; 16 } 17 if(scale == undefined) { 18 scale = false; 19 } 20 if(overview == undefined) { 21 overview = false; 22 } 23 if(map_type == undefined || map_type == 'map') { 24 map_type = G_NORMAL_MAP; 25 } 26 else if(map_type == 'satellite') { 27 map_type = G_SATELLITE_MAP; 1 function createMap(map_id, lat, lng, zoom, mapType, typeCtl, navCtl) { 2 var options = { 3 zoom: zoom, 4 center: new google.maps.LatLng(lat, lng), 5 }; 6 options.mapTypeId = eval("google.maps.MapTypeId." + mapType); 7 8 if (typeCtl != null) { 9 if (typeCtl == "hide") { 10 options.mapTypeControl = false; 11 } 12 else { 13 options.mapTypeControl = true; 14 options.mapTypeControlOptions = {}; 15 options.mapTypeControlOptions.style = eval("google.maps.MapTypeControlStyle." + typeCtl); 16 } 28 17 } 29 18 30 // Create map 31 var gmap = new GMap2(document.getElementById(map_id)); 32 // set center 33 gmap.setCenter(new GLatLng(lat, lng), zoom, map_type); 34 // map control 35 if (map == 'large') { 36 gmap.addControl(new GLargeMapControl()); 19 if (navCtl != null) { 20 if (navCtl == "hide") { 21 options.navigationControl = false; 22 } 23 else { 24 options.navigationControl = true; 25 options.navigationControlOptions = {}; 26 options.navigationControlOptions.style = eval("google.maps.NavigationControlStyle." + navCtl); 27 } 37 28 } 38 else if (map == 'small') { 39 gmap.addControl(new GSmallMapControl()); 40 } 41 else if (map == 'zoom') { 42 gmap.addControl(new GSmallZoomControl()); 43 } 44 // map type control 45 if (type == 'small') { 46 gmap.addControl(new GMapTypeControl(true)); 47 } 48 else if (type) { 49 gmap.addControl(new GMapTypeControl()); 50 } 51 // scale control 52 if (scale) { 53 gmap.addControl(new GScaleControl()); 54 } 55 // overview control 56 if (overview) { 57 gmap.addControl(new GOverviewMapControl()); 58 } 59 return gmap; 29 30 return new google.maps.Map(document.getElementById(map_id), options); 60 31 } 61 32 62 url = "<dtml-var portal_url>" 33 function createMarker(map, lat, lng, title) { 34 var marker = new google.maps.Marker({ 35 position: new google.maps.LatLng(lat, lng), 36 map: map, 37 title: title 38 }); 39 40 var infowindow = new google.maps.InfoWindow({ 41 content: "<div>" + title + "</div>" 42 }); 43 44 google.maps.event.addListener(marker, 'click', function() { 45 infowindow.open(map, marker); 46 }); 47 return marker; 48 } 49 50 var url = "<dtml-var portal_url>" 51 52 /* 63 53 // Create marker icon 64 54 var icon = new GIcon(); … … 78 68 center_icon.iconAnchor = new GPoint( 11 , 11 ); 79 69 80 // Create markers and events 81 function createMarker(map, lat, lng) { 82 var point = new GLatLng(lat, lng); 83 var marker = new GMarker(point, icon); 84 map.addOverlay(marker); 85 return marker; 86 } 87 88 function addMarker(map, tabs, marker_id, lat, lng) { 89 var point = new GLatLng(lat, lng); 90 var marker = new GMarker(point, icon); 91 map.addOverlay(marker); 92 f = function() {marker.openInfoWindowTabsHtml(tabs)}; 93 GEvent.addListener(marker, 'click', f); 94 var marker_field = document.getElementById('marker_link_'+ marker_id); 95 if(marker_field){ 96 marker_field.onmousedown = f; 97 } 98 } 99 100 function addCenterMarker(map) { 101 var center_marker = new GMarker(map.getCenter(), center_icon); 102 map.addOverlay(center_marker); 103 104 GEvent.addListener(map , "moveend" , function() { 105 map.removeOverlay(center_marker); 106 center_marker = new GMarker(map.getCenter(), center_icon); 107 map.addOverlay(center_marker); 108 }); 109 } 110 70 */ -
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.
