+9
-1
@@ -56,7 +56,7 @@ except ImportError:
|
|||||||
import gluon.contrib.simplejson as json_parser
|
import gluon.contrib.simplejson as json_parser
|
||||||
|
|
||||||
__all__ = ['Mail', 'Auth', 'Recaptcha', 'Crud', 'Service', 'Wiki',
|
__all__ = ['Mail', 'Auth', 'Recaptcha', 'Crud', 'Service', 'Wiki',
|
||||||
'PluginManager', 'fetch', 'geocode', 'prettydate']
|
'PluginManager', 'fetch', 'geocode', 'reverse_geocode', 'prettydate']
|
||||||
|
|
||||||
### mind there are two loggers here (logger and crud.settings.logger)!
|
### mind there are two loggers here (logger and crud.settings.logger)!
|
||||||
logger = logging.getLogger("web2py")
|
logger = logging.getLogger("web2py")
|
||||||
@@ -4425,6 +4425,14 @@ def geocode(address):
|
|||||||
return (0.0, 0.0)
|
return (0.0, 0.0)
|
||||||
|
|
||||||
|
|
||||||
|
def reverse_geocode(lat, lng, lang=current.T.accepted_language):
|
||||||
|
""" Try to get an approximate address for a given latitude, longitude. """
|
||||||
|
try:
|
||||||
|
return json_parser.loads(fetch('http://maps.googleapis.com/maps/api/geocode/json?latlng=%(lat)s,%(lng)s&language=%(lang)s' % locals()))['results'][0]['formatted_address']
|
||||||
|
except:
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def universal_caller(f, *a, **b):
|
def universal_caller(f, *a, **b):
|
||||||
c = f.func_code.co_argcount
|
c = f.func_code.co_argcount
|
||||||
n = f.func_code.co_varnames[:c]
|
n = f.func_code.co_varnames[:c]
|
||||||
|
|||||||
Reference in New Issue
Block a user