Changeset 381
- Timestamp:
- 07/06/06 10:27:51
- Files:
-
- geolocation/trunk/adapter.py (modified) (2 diffs)
- geolocation/trunk/browser/edit_location.pt (modified) (2 diffs)
- geolocation/trunk/browser/location.py (modified) (1 diff)
- geolocation/trunk/interface.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
geolocation/trunk/adapter.py
r380 r381 38 38 self.geolocation['latitude'] = float(value) 39 39 40 def setLocation(self, l ongitude, latitude):40 def setLocation(self, latitude, longitude): 41 41 """ set location """ 42 42 self.geolocation['longitude'] = float(longitude) … … 47 47 def geoLocation(obj, portal, **kw): 48 48 """ return the location list """ 49 if hasattr(obj , 'geoLocation'):49 if hasattr(obj.aq_base, 'geoLocation'): 50 50 return obj.geoLocation() 51 51 adapter = IGEOLocated(obj, None) 52 52 if adapter: 53 l ong = adapter.getLongitude()53 lng = adapter.getLongitude() 54 54 lat = adapter.getLatitude() 55 if not long or lat:55 if not (lat or lng): 56 56 return None 57 57 else: 58 return (l ong, lat)58 return (lat, lng) 59 59 return default 60 60 """ geolocation/trunk/browser/edit_location.pt
r380 r381 6 6 xmlns:i18n="http://xml.zope.org/namespaces/i18n" 7 7 i18n:domain="quills"> 8 9 <head> 10 <metal:block fill-slot="javascript_head_slot"> 11 12 <script type="text/javascript" src="" 13 tal:define="key python:modules['Products.qPloneGoogleMaps.config'].MAP_API_KEY" 14 tal:attributes="src string:http://maps.google.com/maps?file=api&v=2&key=${key}"> 15 </script> 16 <script type="text/javascript"> 17 function editLocation(){ 18 if (GBrowserIsCompatible()) { 19 var lat = document.getElementById('latitude'), 20 lng = document.getElementById('longitude'), 21 lat_val = lat.value, 22 lng_val = lng.value, 23 map = new GMap2(document.getElementById('map')), 24 button = document.getElementById('cancel_button'); 25 f = function(){ 26 lat.value = lat_val, 27 lng.value = lng_val; 28 map.clearOverlays(); 29 addMarker(lat_val, lng_val); 30 }; 31 if (button.addEventListener) button.addEventListener("click", f, false); 32 else if (button.attachEvent) button.attachEvent("onclick", f); 33 34 map.addControl(new GLargeMapControl()); 35 map.addControl(new GMapTypeControl()); 36 map.addControl(new GOverviewMapControl()); 37 map.setCenter(new GLatLng(parseFloat(lat.value), parseFloat(lng.value)), 6); 38 39 function addMarker(lat, lng){ 40 var point = new GLatLng(lat, lng); 41 var marker = new GMarker(point) 42 map.addOverlay(marker); 43 }; 44 45 var listener = function(marker, point) { 46 if (!marker){ 47 map.clearOverlays(); 48 addMarker(point.y, point.x); 49 lat.value = point.y; 50 lng.value = point.x; 51 } 52 }; 53 54 GEvent.addListener(map, 'click', listener); 55 addMarker(parseFloat(lat.value), parseFloat(lng.value)); 56 } 57 else window.alert("Google maps aren't compatible with current Browser.");}; 58 59 registerPloneFunction(editLocation); 60 </script> 61 62 </metal:block> 63 </head> 8 64 9 65 <body> … … 20 76 Edit location coordinates 21 77 </legend> 78 79 <div class="field"> 80 <label i18n:translate="label_latitude"> 81 Latitude 82 </label> 83 <input type="text" name="latitude" id="latitude" 84 tal:attributes="value location/latitude" /> 85 </div> 86 22 87 <div class="field"> 23 88 <label i18n:translate="label_longitude"> 24 89 Longitude 25 90 </label> 26 <input type="text" name="longitude" 91 <input type="text" name="longitude" id="longitude" 27 92 tal:attributes="value location/longitude" /> 28 93 </div> 29 <div class="field"> 30 <label i18n:translate="label_latitude"> 31 Latitude 32 </label> 33 <input type="text" name="latitude" 34 tal:attributes="value location/latitude" /> 35 </div> 36 94 37 95 <div class="formControls"> 38 <input type="submit" 96 <input type="submit" 97 class="context" 39 98 name="editLocation:method" 40 99 value="Save" /> 100 <input type="button" 101 class="standalone" 102 id="cancel_button" 103 name="cancel_button" 104 value="Cancel" /> 41 105 </div> 42 106 </fieldset> 43 107 </form> 108 109 <div id="map" style="position: relative; height: 480px;"></div> 110 44 111 </tal:x> 45 112 <tal:x condition="not:location/location"> geolocation/trunk/browser/location.py
r380 r381 17 17 self.request = request 18 18 self.location = IGEOLocated(self.context, None) 19 self.latitude = self.location and self.location.getLatitude() or 0 19 20 self.longitude = self.location and self.location.getLongitude() or 0 20 self.latitude = self.location and self.location.getLatitude() or 021 21 22 def editLocation(self, longitude=None, latitude=None):22 def editLocation(self, latitude=None, longitude=None): 23 23 """ update location properties """ 24 self.location.setLocation(l ongitude, latitude)24 self.location.setLocation(latitude, longitude) 25 25 self.context.reindexObject() 26 26 geolocation/trunk/interface.py
r380 r381 30 30 """ set latitutde """ 31 31 32 def setLocation(l ongitude, latitude):32 def setLocation(latitude, longitude): 33 33 """ set location """ 34 34 … … 37 37 """ 38 38 39 def editLocation(self, l ongitude, latitude):39 def editLocation(self, latitude, longitude): 40 40 """ update location properties """
