diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-01-21 20:05:47 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-01-21 20:05:47 +0100 |
commit | b834a47ecafc41d5bafe38e7b085b2845406a47c (patch) | |
tree | 347edf5446fba447703cd93cf47e3124d01e46be /chimere/models.py | |
parent | d5bcdc7eab034a1770335190fb9ebc09c3e6d3f6 (diff) | |
download | Chimère-b834a47ecafc41d5bafe38e7b085b2845406a47c.tar.bz2 Chimère-b834a47ecafc41d5bafe38e7b085b2845406a47c.zip |
OL3: marker and popup OK
Diffstat (limited to 'chimere/models.py')
-rw-r--r-- | chimere/models.py | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/chimere/models.py b/chimere/models.py index b5f03cc..98dbd22 100644 --- a/chimere/models.py +++ b/chimere/models.py @@ -203,7 +203,9 @@ class Icon(models.Model): height = models.IntegerField(_(u"Height")) width = models.IntegerField(_(u"Width")) offset_x = models.IntegerField(_(u"Offset x"), default=10) - offset_y = models.IntegerField(_(u"Offset y"), default=25) + offset_y = models.IntegerField(_(u"Offset y"), default=20) + popup_offset_x = models.IntegerField(_(u"Popup offset x"), default=5) + popup_offset_y = models.IntegerField(_(u"Popup offset y"), default=20) def __unicode__(self): return self.name @@ -298,7 +300,10 @@ class SubCategory(models.Model): 'width': self.icon.image.width, 'height': self.icon.image.height, 'offset_x': self.icon.offset_x, - 'offset_y': self.icon.offset_y}} + 'offset_y': self.icon.offset_y, + 'popup_offset_x': self.icon.popup_offset_x, + 'popup_offset_y': self.icon.popup_offset_y} + } if self.hover_icon: items['icon_hover'] = {'url': self.hover_icon.image.url} @@ -689,22 +694,28 @@ class Marker(GeographicItem): '''Return a GeoJSON string ''' jsons = [] - json_tpl = {"type":"Feature", "properties":{}} + json_tpl = {"type": "Feature", "properties": {}} for cat in self.categories.all(): if categories_id and cat.id not in categories_id: continue items = copy.deepcopy(json_tpl) items['geometry'] = json.loads(self.point.geojson) items['properties'].update({ - 'pk':self.id, - 'name':self.name, - 'icon_path':unicode(cat.icon.image), - 'icon_hover_path':unicode(cat.hover_icon.image) \ - if cat.hover_icon else '', - 'category_name':cat.name}) + 'pk': self.id, + 'name': self.name, + 'icon_path': unicode(cat.icon.image), + 'icon_hover_path': unicode(cat.hover_icon.image) + if cat.hover_icon else '', + 'icon_offset_x': cat.icon.offset_x, + 'icon_offset_y': cat.icon.offset_y, + 'icon_popup_offset_x': cat.icon.popup_offset_x, + 'icon_popup_offset_y': cat.icon.popup_offset_y, + 'category_name': cat.name}) try: - items['properties'].update({'icon_width':cat.icon.image.width, - 'icon_height':cat.icon.image.height,}) + items['properties'].update( + {'icon_width': cat.icon.image.width, + 'icon_height': cat.icon.image.height, + }) except IOError: pass |