diff options
| author | etienne <etienne@9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864> | 2008-11-04 00:06:58 +0000 | 
|---|---|---|
| committer | etienne <etienne@9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864> | 2008-11-04 00:06:58 +0000 | 
| commit | 6f97020d6b56f19d37a0941b299e68b2e8837d68 (patch) | |
| tree | 1fcda40375cc872cbf26928e66482f30d5e8cf61 | |
| parent | 030ed86130fabc78695355021b5a0586df3e77b9 (diff) | |
| download | Chimère-6f97020d6b56f19d37a0941b299e68b2e8837d68.tar.bz2 Chimère-6f97020d6b56f19d37a0941b299e68b2e8837d68.zip | |
Icon dimensions are automatically got from the file for correct display on the map
git-svn-id: http://www.peacefrogs.net/svn/chimere/trunk@2 9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864
| -rw-r--r-- | main/models.py | 20 | ||||
| -rw-r--r-- | static/main_map.js | 2 | ||||
| -rw-r--r-- | urls.py | 2 | 
3 files changed, 16 insertions, 8 deletions
| diff --git a/main/models.py b/main/models.py index 6d673d8..d4ba9be 100644 --- a/main/models.py +++ b/main/models.py @@ -27,7 +27,8 @@ class Icon(models.Model):      '''Icon      '''      name = models.CharField(_("Name"), max_length=150) -    image = models.ImageField(_("Image"), upload_to='icons') +    image = models.ImageField(_("Image"), upload_to='icons', +                              height_field='height', width_field='width')      def __unicode__(self):          return self.name      class Meta: @@ -67,7 +68,8 @@ class Marker(models.Model):      name = models.CharField(_("Name"), max_length=150)      subcategory = models.ForeignKey(SubCategory, verbose_name=_("Subcategory"))      point = PointField(_("Localisation")) -    picture = models.ImageField(_("Image"), upload_to='upload', blank=True) +    picture = models.ImageField(_("Image"), upload_to='upload', blank=True, +                                height_field='height', width_field='width')      STATUS = (('S', _('Submited')),                ('A', _('Available')),                ('D', _('Disabled')),) @@ -120,10 +122,16 @@ class Marker(models.Model):      def getGeoJSON(self):          '''Return a GeoJSON string          ''' -        return """{"type":"Feature", "geometry":{"type":"Point", "crs": "EPSG:%(epsg)d", "coordinates":[%(longitude)s, %(latitude)s]}, "properties":{"pk": %(id)d, "name": "%(name)s", "icon_path":"%(icon_path)s"}}""" \ - % {'id':self.id, 'name':self.name, 'icon_path':self.subcategory.icon.image, -'latitude':self.getLatitude(), 'longitude':self.getLongitude(), -'epsg':settings.EPSG_PROJECTION} +        print self.subcategory.icon.image +        return """{"type":"Feature", "geometry":{"type":"Point", \ +"crs": "EPSG:%(epsg)d", "coordinates":[%(longitude)s, %(latitude)s]}, \ +"properties":{"pk": %(id)d, "name": "%(name)s", \ +"icon_path":"%(icon_path)s", "icon_width":%(icon_width)d, \ +"icon_height":%(icon_height)d}}""" % {'id':self.id, 'name':self.name, +'icon_path':self.subcategory.icon.image, 'latitude':self.getLatitude(), +'longitude':self.getLongitude(), 'epsg':settings.EPSG_PROJECTION, +'icon_width':self.subcategory.icon.image.width, +'icon_height':self.subcategory.icon.image.height,}  class PropertyModel(models.Model):      '''Model for a property diff --git a/static/main_map.js b/static/main_map.js index 9bb703f..1d5d845 100644 --- a/static/main_map.js +++ b/static/main_map.js @@ -86,6 +86,8 @@ function putMarker(mark) {      marker */      lat = mark.geometry.coordinates[1];      lon = mark.geometry.coordinates[0]; +    var size = new OpenLayers.Size(mark.properties.icon_width, +                                   mark.properties.icon_height);      iconclone = new OpenLayers.Icon(media_path + mark.properties.icon_path,                                      size, offset);      var feature = new OpenLayers.Feature(markers, @@ -17,8 +17,6 @@ urlpatterns = patterns('',       (r'^chimere/getMarkers/(?P<category_ids>\w+)/$',                   'chimere.main.views.getMarkers'),       (r'^chimere/static/(?P<path>.*)$', 'django.views.static.serve', -                              {'document_root': 'static/'}), -     (r'^chimere/static/(?P<path>.*)$', 'django.views.static.serve',                            {'document_root': ROOT_PATH + 'static/'}),       (r'^chimere/media/(?P<path>.*)$', 'django.views.static.serve',                             {'document_root': ROOT_PATH + 'media/'}), | 
