Ticket #9440: overlays.py.patch
File overlays.py.patch, 1.8 KB (added by , 16 years ago) |
---|
-
(a) overlays.py vs. (b) /media/disk/--
a b 184 184 return render_to_response('mytemplate.html', 185 185 {'google' : GoogleMap(markers=[marker])}) 186 186 """ 187 def __init__(self, geom, title=None ):187 def __init__(self, geom, title=None, icon=None): 188 188 """ 189 189 The GMarker object may initialize on GEOS Points or a parameter 190 190 that may be instantiated into a GEOS point. Keyword options map to … … 193 193 Keyword Options: 194 194 title: 195 195 Title option for GMarker, will be displayed as a tooltip. 196 icon: 197 Icon option(s) for GMarker ({path, width, height} or just "path" as a string) 196 198 """ 197 199 # If a GEOS geometry isn't passed in, try to construct one. 198 200 if isinstance(geom, basestring): geom = fromstr(geom) … … 205 207 self.envelope = geom.envelope 206 208 # TODO: Add support for more GMarkerOptions 207 209 self.title = title 210 if(isinstance(icon, basestring)): icon = {'path': icon} 211 self.icon = icon 208 212 super(GMarker, self).__init__() 209 213 210 214 def latlng_from_coords(self, coords): … … 213 217 def options(self): 214 218 result = [] 215 219 if self.title: result.append('title: "%s"' % self.title) 220 if self.icon: result.append('icon: %s' % self.getIcon()) 216 221 return '{%s}' % ','.join(result) 217 222 223 def getIcon(self): 224 params = [] 225 params.append("""'%s'""" % self.icon['path']); 226 if (self.icon.has_key('width') and self.icon.has_key('height')): 227 params.append(self.icon['width']); 228 params.append(self.icon['height']); 229 230 s = """gmap_getIcon(%s)""" % ",".join(params); 231 return s 232 218 233 @property 219 234 def js_params(self): 220 235 return '%s, %s' % (self.latlng, self.options()) 236