我遵循了http://code.google.com/p/geopy/wiki/GettingStarted中的教程--这很好:
g = geocoders.Google(resource='maps')我想使用json作为输出格式,因为我希望处理javascript中的结果。
但每次我用:
g = geocoders.Google(resource='maps', output_format='json')我得到的错误如下:
Environment:
Request Method: GET
Request URL: http://localhost:8000/business/view/13/
Django Version: 1.2.1
Python Version: 2.5.1
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'registration',
'pley.business',
'pley.review',
'django.contrib.admin',
'django.contrib.webdesign']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "C:\Python25\Lib\site-packages\django\core\handlers\base.py" in get_response
100. response = callback(request, *callback_args, **callback_kwargs)
File "C:\django\pley\..\pley\business\views.py" in business_view
57. for place, (lat, lng) in g.geocode(string_location,exactly_one=False):
File "c:\python25\lib\site-packages\geopy-0.94-py2.5.egg\geopy\geocoders\google.py" in geocode
66. return self.geocode_url(url, exactly_one)
File "c:\python25\lib\site-packages\geopy-0.94-py2.5.egg\geopy\geocoders\google.py" in geocode_url
73. return dispatch(page, exactly_one)
File "c:\python25\lib\site-packages\geopy-0.94-py2.5.egg\geopy\geocoders\google.py" in parse_json
123. json = simplejson.loads(page)
File "C:\Python25\lib\site-packages\simplejson-2.1.1-py2.5-win32.egg\simplejson\__init__.py" in loads
384. return _default_decoder.decode(s)
File "C:\Python25\lib\site-packages\simplejson-2.1.1-py2.5-win32.egg\simplejson\decoder.py" in decode
402. obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Python25\lib\site-packages\simplejson-2.1.1-py2.5-win32.egg\simplejson\decoder.py" in raw_decode
420. raise JSONDecodeError("No JSON object could be decoded", s, idx)
Exception Type: JSONDecodeError at /business/view/13/
Exception Value: No JSON object could be decoded: line 1 column 0 (char 0)如有任何意见/答复,将不胜感激。
谢谢!
发布于 2010-07-27 19:46:46
你看过地质公园页面上的评论了吗?
评论: gregor.horvath,2009年9月11日
请注意,尽管大地编码器有不同的output_format参数,但实际的地理代码函数的输出格式总是相同的:
位置(纬度、经度)
output_format仅指地编码器服务(Google等)的输出,而不是地码函数.的输出。
https://stackoverflow.com/questions/3344747
复制相似问题