Changeset 381

Show
Ignore:
Timestamp:
07/06/06 10:27:51
Author:
piv
Message:

shifted longitude with latitude, added js to edit_location

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • geolocation/trunk/adapter.py

    r380 r381  
    3838        self.geolocation['latitude'] = float(value) 
    3939     
    40     def setLocation(self, longitude, latitude): 
     40    def setLocation(self, latitude, longitude): 
    4141        """ set location """ 
    4242        self.geolocation['longitude'] = float(longitude) 
     
    4747def geoLocation(obj, portal, **kw): 
    4848    """ return the location list """ 
    49     if hasattr(obj, 'geoLocation'): 
     49    if hasattr(obj.aq_base, 'geoLocation'): 
    5050        return obj.geoLocation() 
    5151    adapter = IGEOLocated(obj, None) 
    5252    if adapter: 
    53         long = adapter.getLongitude() 
     53        lng = adapter.getLongitude() 
    5454        lat = adapter.getLatitude() 
    55         if not long or lat
     55        if not (lat or lng)
    5656            return None 
    5757        else: 
    58             return (long, lat
     58            return (lat, lng
    5959    return default 
    6060""" 
  • geolocation/trunk/browser/edit_location.pt

    r380 r381  
    66      xmlns:i18n="http://xml.zope.org/namespaces/i18n" 
    77      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&amp;v=2&amp;key=${key}"> 
     15    </script> 
     16    <script type="text/javascript"> 
     17function 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> 
    864 
    965  <body> 
     
    2076              Edit location coordinates 
    2177            </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 
    2287            <div class="field"> 
    2388              <label i18n:translate="label_longitude"> 
    2489                Longitude 
    2590              </label> 
    26               <input type="text" name="longitude" 
     91              <input type="text" name="longitude" id="longitude" 
    2792                        tal:attributes="value location/longitude" /> 
    2893            </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 
    3795            <div class="formControls"> 
    38               <input type="submit"  
     96              <input type="submit" 
     97                     class="context" 
    3998                     name="editLocation:method"  
    4099                     value="Save" /> 
     100              <input type="button" 
     101                     class="standalone" 
     102                     id="cancel_button" 
     103                     name="cancel_button" 
     104                     value="Cancel" /> 
    41105            </div> 
    42106          </fieldset> 
    43107        </form> 
     108 
     109        <div id="map" style="position: relative; height: 480px;"></div> 
     110 
    44111        </tal:x> 
    45112        <tal:x condition="not:location/location"> 
  • geolocation/trunk/browser/location.py

    r380 r381  
    1717        self.request = request 
    1818        self.location = IGEOLocated(self.context, None) 
     19        self.latitude = self.location and self.location.getLatitude() or 0 
    1920        self.longitude = self.location and self.location.getLongitude() or 0 
    20         self.latitude = self.location and self.location.getLatitude() or 0 
    2121  
    22     def editLocation(self,longitude=None, latitude=None): 
     22    def editLocation(self, latitude=None, longitude=None): 
    2323        """ update location properties """ 
    24         self.location.setLocation(longitude, latitude) 
     24        self.location.setLocation(latitude, longitude) 
    2525        self.context.reindexObject() 
    2626         
  • geolocation/trunk/interface.py

    r380 r381  
    3030        """ set latitutde """ 
    3131 
    32     def setLocation(longitude, latitude): 
     32    def setLocation(latitude, longitude): 
    3333       """ set location  """ 
    3434 
     
    3737    """ 
    3838 
    39     def editLocation(self, longitude, latitude): 
     39    def editLocation(self, latitude, longitude): 
    4040        """ update location properties """