Ticket #9204: gicon1.patch
File gicon1.patch, 2.6 KB (added by , 16 years ago) |
---|
-
__init__.py
57 57 version. 58 58 """ 59 59 from django.contrib.gis.maps.google.gmap import GoogleMap 60 from django.contrib.gis.maps.google.overlays import GEvent, GMarker, GPolygon, GPolyline 60 from django.contrib.gis.maps.google.overlays import GEvent, GMarker, GPolygon, GPolyline, GIcon 61 61 from django.contrib.gis.maps.google.zoom import GoogleZoom -
overlays.py
165 165 def js_params(self): 166 166 return '%s, "%s", %s, %s' % (self.latlngs, self.color, self.weight, self.opacity) 167 167 168 class GIcon(object): 169 """ 170 A Python wrapper for the Google GIcon object. For more information 171 please see the Google Maps API Reference: 172 http://code.google.com/apis/maps/documentation/reference.html#GIcon 173 174 >>> GIcon("http://gmaps-samples.googlecode.com/svn/trunk/markers/blue/blank.png") 175 <django.contrib.gis.maps.google.overlays.GIcon object at 0x132c6d0> 176 >>> "%s"%GIcon("http://gmaps-samples.googlecode.com/svn/trunk/markers/blue/blank.png") 177 'icon: eval("icon=new GIcon(G_DEFAULT_ICON);icon.image=\'http://gmaps-samples.googlecode.com/svn/trunk/markers/blue/blank.png\';icon")' 178 """ 179 def __init__(self, icon=None): 180 self.icon = icon 181 182 def __str__(self): 183 js = "" 184 if self.icon: js='''icon: eval("icon=new GIcon(G_DEFAULT_ICON);icon.image='%s';icon")''' % self.icon 185 return js 186 187 168 188 class GMarker(GOverlayBase): 169 189 """ 170 190 A Python wrapper for the Google GMarker object. For more information … … 184 204 return render_to_response('mytemplate.html', 185 205 {'google' : GoogleMap(markers=[marker])}) 186 206 """ 187 def __init__(self, geom, title=None ):207 def __init__(self, geom, title=None, icon=None): 188 208 """ 189 209 The GMarker object may initialize on GEOS Points or a parameter 190 210 that may be instantiated into a GEOS point. Keyword options map to … … 205 225 self.envelope = geom.envelope 206 226 # TODO: Add support for more GMarkerOptions 207 227 self.title = title 228 self.icon = icon 208 229 super(GMarker, self).__init__() 209 230 210 231 def latlng_from_coords(self, coords): … … 213 234 def options(self): 214 235 result = [] 215 236 if self.title: result.append('title: "%s"' % self.title) 237 if self.icon: result.append("%s"%self.icon) 216 238 return '{%s}' % ','.join(result) 217 239 218 240 @property