Django的Google Maps Geocoding错误

时间:2011-07-24 18:19:26

标签: python django google-maps simplejson

在这里试图找出问题的几个小时之后,我已经放弃了。我正在使用http://djangosnippets.org/snippets/2241/(保存在myproject / custom.py中)查询Google并返回该位置的坐标。我的功能的开头是:

def locQuery(location **kwargs):
    """
    This function returns a queryset of locations based on a Google Geocode
    lookup and other parameters
    """
    q = GoogleLatLng()
    query = MyModel.objects.none()
    try:
        q.requestLatLngJSON(location)
    except:
        return query
    # Do something based on kwargs #

但是,我间歇性地收到以下错误:

>>> locQuery('York')
Traceback (most recent call last):
  File "/home/../myproject/custom.py", line 85, in parseResults
    self.results = json.loads(buff)
  File "/usr/local/lib/python2.7/json/__init__.py", line 326, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python2.7/json/decoder.py", line 360, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python2.7/json/decoder.py", line 376, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Expecting object: line 37 column 8 (char 1133)
[]

以下是代码正常工作的示例:

>>> locQuery('York')
[]

任何帮助都会很棒。

编辑: 所以我最终决定片段本身有问题。我现在使用http://code.google.com/apis/maps/documentation/webservices/index.html#ParsingJSON上提供的python代码来执行我的地理编码查询...

0 个答案:

没有答案