开发者

Changing input for the Google Map API

I'm trying to use Google Map API in my GAE app but having trouble making it the way i want it to be. Im trying to use the code examples from gecoding-simple http://code.google.com/intl/en/apis/maps/documentation/javascript/examples/geocoding-simple.html

I'm trying to display the map of where my event take place which is from

class Event(db.Model):
   title = db.StringProperty(required=True)
   description = db.TextProperty()
   time = db.DateTimeProperty()
   location = db.PostalAddressProperty()
   creator = db.UserProperty()
   edit_link = db.TextProperty()
   gcal_event_link = db.TextProperty()
   gcal_event_xml = db.TextProperty()
   hobby = db.ReferenceProperty(Hobby)

Instead of having the text field and type where the marker would be, I would like to put the marker from Event.location

var address = {{event.location}};
geocoder.geocode( { 'address': address}, function(results, status)

i've changed var address = document.getElementById("address").value to {{event.location}} thought thats what i have to do... but it doesnt work...

How do i do that... where do i have to change the example code.

event is created in the following class.

class CreateEvent(BasePage):
title = 'Create!'

def get(self):
  """Show the event creation form"""
  self.write_page_header()
  template_values = {}
  path = os.path.join(os.path.dirname(__file__), 'templates')
  path = os.path.join(path, 'create.html')
  self.response.out.write(template.render(path, template_values))
  self.write_page_footer()

def post(self):
  """Create an event and store it in the datastore.

  This event does not exist in Google Calendar. The event creator can add it
  to Google Calendar on the 'events' page.
  """
  self.write_page_header()


if self.request.get("hobby"):
  hobby_name = self.request.get('hobby')
  new_hobby = Hobby(name=hobby_name.strip(), key_name = hobby_name.strip())

# Create an event in the datastore.
new_event = Event(title=self.request.get('name'),
                  creator=users.get_c开发者_运维技巧urrent_user(),
                  # Take the time string passing in by JavaScript in the
                  # form and convert to a datetime object.
                  time=datetime.datetime.strptime(
                      self.request.get('datetimestamp'), '%d/%m/%Y %H:%M'),
                  description=self.request.get('description'),
                  location=self.request.get('location'),
                  hobby = new_hobby)
new_event.put()

info.html is the following

<h1 id="header">Event Info</h1>
<p>Name: {{event.title|escape}}</p>
<p>Description: {{event.description|escape}}</p>
<p>Location: {{event.location|escape}}</p>
<p>Attendee: {{event.attendee.email|escape}}</p>
<p>When: {{event.time}} (UTC)</p>

{% for greeting in greetings %}
  {% if greeting.author %}
    <b>{{ greeting.author.nickname }}</b> wrote:
  {% else %}
   An anonymous person wrote:
  {% endif %}
  <blockquote>{{ greeting.content|escape }}</blockquote>
{% endfor %}



<form action="/sign" method="post">
  <div><textarea name="content" rows="3" cols="60"></textarea></div>
  <div><input type="submit" value="Write on the Wall"></div>
</form>


google map API follows here.  

Thanx in advance.


var address = 'London';
geocoder.geocode({ 'address': address }, function (results, status)

Seems to be working fine at my side. Do you get any errors?

Why is your event.location framed with double brackets? Maybe thats causeing the Problem?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜