5

私の Web サイト (サーバー側で python/django を使用) は、Latlng (Google Maps API 2) ジオコードのユーザー入力を受け取り、それを Google Appengine Datastore に保存/取得します。

        c = myplace.MyPlace(
            geo_point = latlng,
        c.put()

ここで、DB.Model は次のように定義されます。

from google.appengine.ext import db

class Myplace(db.Model):
    geo_point   = db.GeoPtProperty()

問題は、任意の を保存するgeocode(e.g. 8.928487062665504, 105.062255859375)と、取得されるのは常に37.4229181,-122.0854212であり、これは Google のマウンテン ビューの場所です。このプロセス中にエラー メッセージは表示されません。

なぜこれが起こるのか教えていただけますか?


ShopInfo.py ...

def new(req):                       
   if req.method == 'POST':
        try:
            u_form = ShopInfoForm(req.POST)
            if not u_form.is_valid():
                return err_page('Invalid input values.')

            # geo_point
            latlng = None
            if req.POST.get('geo_point'):
                latlng = req.POST.get('geo_point').strip()
                latlng = string.replace(latlng, '(', '')
                latlng = string.replace(latlng, ')', '')

            c = myplace.MyPlace(owner = u,
                    nickname = u.nickname,
                    #title = unicode(req.POST['title'].strip(), 'utf8'),
                    #content = unicode(req.POST['content'].strip(), 'utf8'),
                    title = req.POST['title'].strip(),
                    content = req.POST['content'].strip(),
                    geo_point = latlng,
                    post_time = datetime.now())
            c.put()                  ##WRITE HERE

            return HttpResponseRedirect('/shop/'+str(c.key().id())+'/read/')
        except Exception, x:
            return err_page('Error.')
    return err_page('Wrong request')

def read(req, shop_id):         
    if req.method == 'GET':
        user_info = users.get_current_user()
        s = myplace.MyPlace.get_by_id(int(shop_id))  
        if not s:
            return err_page('Wrong request')

        context = {'static_path': STATIC_PATH,
                   'user_info': user_info,
                   'shop' : s}            ##READ HERE
        return render_to_response('shop_read.html', context)
    return err_page('Wrong request')

**shop_read.html**

    {% if shop.geo_point %}
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=" type="text/javascript"></script>
<script src="http://www.google.com/jsapi"></script>
<script type="text/javascript">google.load("jquery", "1");</script>
<script type="text/javascript">
4

0 に答える 0