Skip to content

Commit

Permalink
Added Marker support for the GMap
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolmo committed Jun 1, 2009
1 parent e2fdb64 commit b8d498c
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions myapp/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ class - Name of the GMap class to addOverlay with default options or user overri
'numLevels': 4
}

marker_options = {}

@classmethod
def render_values(cls, page, path = ''):
cls.callback = page.request.get('callback')
Expand All @@ -147,7 +149,7 @@ def render_values(cls, page, path = ''):
try:
getattr(cls, 'render_%s' % page.request.get('type', 'raw'))(page, get)
except Exception, msg:
cls.render(page, '/* Check the "type" parameter */')
cls.render(page, '/* Check the "type" parameter :: %s*/' % msg)

@classmethod
def render_raw(cls, page, get):
Expand All @@ -174,7 +176,22 @@ def render_encode(cls, page, get):
if cls.callback:
options = '%s(%s);' % (cls.callback, options)
return cls.render(page, options)


@classmethod
def render_markers(cls, page, get):
template = '''
(function(options){
%s
})(%s);
'''
data = cls.get_values(page.campaign, page.namespace) # todo: generator
data = 'return {markers: [%s], options: options};' % ', '.join(['new GMarker(new GLatLng(%f,%f), options)' % (datum.latitude, datum.longitude) for datum in data])
if cls.callback:
data = '%s(%s);' % (cls.callback, data[7:-1])
marker_options = cls.marker_options.copy()
marker_options.update(get)
return cls.render(page, template % (data, marker_options))

@staticmethod
def encode(points):
""" Encode a coordinates into an encoded string.
Expand Down

0 comments on commit b8d498c

Please sign in to comment.