Ticket #9440: overlays.py.patch

File overlays.py.patch, 1.8 KB (added by aromano, 16 years ago)
  • (a) overlays.py vs. (b) /media/disk/--

    a b  
    184184          return render_to_response('mytemplate.html',
    185185                 {'google' : GoogleMap(markers=[marker])})
    186186    """
    187     def __init__(self, geom, title=None):
     187    def __init__(self, geom, title=None, icon=None):
    188188        """
    189189        The GMarker object may initialize on GEOS Points or a parameter
    190190        that may be instantiated into a GEOS point.  Keyword options map to
     
    193193        Keyword Options:
    194194         title:
    195195           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)
    196198        """
    197199        # If a GEOS geometry isn't passed in, try to construct one.
    198200        if isinstance(geom, basestring): geom = fromstr(geom)
     
    205207        self.envelope = geom.envelope
    206208        # TODO: Add support for more GMarkerOptions
    207209        self.title = title
     210        if(isinstance(icon, basestring)): icon = {'path': icon}
     211        self.icon = icon
    208212        super(GMarker, self).__init__()
    209213
    210214    def latlng_from_coords(self, coords):
     
    213217    def options(self):
    214218        result = []
    215219        if self.title: result.append('title: "%s"' % self.title)
     220        if self.icon: result.append('icon: %s' % self.getIcon())
    216221        return '{%s}' % ','.join(result)
    217222
     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
    218233    @property
    219234    def js_params(self):
    220235        return '%s, %s' % (self.latlng, self.options())
     236
Back to Top