Commit 3fee6680 authored by olb's avatar olb

Add kind field to reference points

parent cc578805
......@@ -37,5 +37,5 @@ class PanoramaAdmin(admin.ModelAdmin):
@admin.register(ReferencePoint)
class ReferencePointAdmin(admin.ModelAdmin):
model = ReferencePoint
list_display = ('name', 'latitude', 'longitude', 'altitude')
fields = ('name', ('latitude', 'longitude'), 'altitude')
list_display = ('name', 'latitude', 'longitude', 'altitude', 'kind')
fields = ('name', ('latitude', 'longitude'), 'altitude', 'kind')
......@@ -35,4 +35,4 @@ class ReferencePointForm(forms.ModelForm):
class Meta:
model = ReferencePoint
fields = ['name', 'latitude', 'longitude', 'altitude']
fields = ['name', 'latitude', 'longitude', 'altitude', 'kind']
# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2017-09-12 21:47
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('panorama', '0004_auto_20150310_1906'),
]
operations = [
migrations.AlterModelOptions(
name='panorama',
options={'verbose_name': 'panorama', 'verbose_name_plural': 'panoramas'},
),
migrations.AlterModelOptions(
name='reference',
options={'verbose_name': 'reference', 'verbose_name_plural': 'references'},
),
migrations.AlterModelOptions(
name='referencepoint',
options={'verbose_name': 'reference point', 'verbose_name_plural': 'reference points'},
),
migrations.AddField(
model_name='referencepoint',
name='kind',
field=models.CharField(choices=[('waiting', 'waiting'), ('subscriber', 'subscriber'), ('other', 'other')], default='waiting', max_length=255, verbose_name='kind'),
),
migrations.AlterField(
model_name='panorama',
name='image_height',
field=models.PositiveIntegerField(default=0, verbose_name='image height'),
),
migrations.AlterField(
model_name='panorama',
name='image_width',
field=models.PositiveIntegerField(default=0, verbose_name='image width'),
),
migrations.AlterField(
model_name='panorama',
name='references',
field=models.ManyToManyField(related_name='referenced_panorama', through='panorama.Reference', to='panorama.ReferencePoint', verbose_name='references'),
),
migrations.AlterField(
model_name='reference',
name='panorama',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='panorama_references', to='panorama.Panorama', verbose_name='panorama'),
),
migrations.AlterField(
model_name='reference',
name='reference_point',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='refpoint_references', to='panorama.ReferencePoint', verbose_name='reference point'),
),
migrations.AlterUniqueTogether(
name='reference',
unique_together=set([]),
),
]
......@@ -107,6 +107,18 @@ class ReferencePoint(Point):
name = models.CharField(verbose_name=_("name"), max_length=255,
help_text=_("Name of the point"))
KIND_OTHER = 'other'
KIND_SUBSCRIBER = 'subscriber'
KIND_WAITING = 'waiting'
KIND_CHOICES = (
(KIND_WAITING, _('waiting')),
(KIND_SUBSCRIBER, _('subscriber')),
(KIND_OTHER, _('other')),
)
kind = models.CharField(verbose_name=_('kind'), max_length=255,
choices=KIND_CHOICES, default=KIND_WAITING)
def __str__(self):
return self.name
......
......@@ -31,6 +31,9 @@ var point_colors = {
'pano_point' : '255,128,128', // red
'ref_point' : '128,128,255', // blue
'loc_point' : '128,255,128', // green
'loc_point_other' : '128,255,128', // green
'loc_point_subscriber' : '255,128,255', // purple
'loc_point_waiting' : '255,196,128', // orange
'temporary' : '255,255,128', // yellow
'unlocated' : '255,255,255' // white
};
......
......@@ -94,12 +94,27 @@
iconAnchor: [11, 35],
popupAnchor: [0,-50]
});
var poiIcon = L.icon({
iconUrl: '{% static "panorama/img/marker-circle-green.png" %}',
iconSize: [20, 20],
iconAnchor: [10, 10],
popupAnchor: [0,-20]
});
var poiIcons = {
subscriber: L.icon({
iconUrl: '{% static "panorama/img/marker-circle-green.png" %}',
iconSize: [20, 20],
iconAnchor: [10, 10],
popupAnchor: [0,-20]
}),
waiting: L.icon({
iconUrl: '{% static "panorama/img/marker-circle-orange.png" %}',
iconSize: [20, 20],
iconAnchor: [10, 10],
popupAnchor: [0,-20]
}),
other: L.icon({
iconUrl: '{% static "panorama/img/marker-circle-purple.png" %}',
iconSize: [20, 20],
iconAnchor: [10, 10],
popupAnchor: [0,-20]
}),
};
var legend = L.control({position: 'bottomright'});
function accordionMenus() {
......@@ -250,9 +265,8 @@
map.addLayer( markerClusters );
// Add POI
var pointsOfInterest = L.layerGroup();
var options = {icon: poiIcon, riseOnHover: true};
{% for poi in poi_list %}
var poiMarker = L.marker([{{ poi.latitude }}, {{ poi.longitude }}], options);
var poiMarker = L.marker([{{ poi.latitude }}, {{ poi.longitude }}], {icon: poiIcons['{{ poi.kind }}'], riseOnHover: true});
var poiPopup = poiMarker.bindPopup('{{ poi.name }}', {className : 'markerpopup', closeButton: false});
poiPopup.on('mouseover', poiMarker.openPopup);
poiPopup.on('mouseout', poiMarker.closePopup);
......@@ -264,7 +278,9 @@
div.innerHTML += '<div class="legendtitle"><p><i class="fa fa-fw fa-caret-down"></i>{% trans "Legend" %}</p></div>';
div.innerHTML += '<img src={% static "panorama/img/marker-red.png" %} ><p>{% trans "Panorama" %}</p></br>';
div.innerHTML += '<img src={% static "panorama/img/marker-blue.png" %} ><p>{% trans "Control" %}</p></br>';
div.innerHTML += '<img src={% static "panorama/img/marker-circle-green.png" %} ><p>{% trans "Point of interest" %}</p></br>';
div.innerHTML += '<img src={% static "panorama/img/marker-circle-green.png" %} ><p>{% trans "Point of interest (subscriber)" %}</p></br>';
div.innerHTML += '<img src={% static "panorama/img/marker-circle-orange.png" %} ><p>{% trans "Point of interest (waiting)" %}</p></br>';
div.innerHTML += '<img src={% static "panorama/img/marker-circle-purple.png" %} ><p>{% trans "Point of interest (other)" %}</p></br>';
return div;
};
map.addLayer(pointsOfInterest);
......
......@@ -27,6 +27,7 @@
{{ newrefpoint_form.latitude.label_tag }}{{ newrefpoint_form.latitude }}
{{ newrefpoint_form.longitude.label_tag }}{{ newrefpoint_form.longitude }}
{{ newrefpoint_form.altitude.label_tag }}{{ newrefpoint_form.altitude }}
{{ newrefpoint_form.kind.label_tag }}{{ newrefpoint_form.kind }}
<input type="submit" class="btn btn-primary btn-sm" value={% trans "Add" %} />
</form>
</li>
......
......@@ -73,14 +73,27 @@
iconAnchor: [11, 35],
popupAnchor: [0,-50]
});
var poiIcon = L.icon({
var poiIcons = {
subscriber: L.icon({
iconUrl: '{% static "panorama/img/marker-circle-green.png" %}',
iconSize: [20, 20],
iconAnchor: [10, 10],
popupAnchor: [0,-20]
});
}),
waiting: L.icon({
iconUrl: '{% static "panorama/img/marker-circle-orange.png" %}',
iconSize: [20, 20],
iconAnchor: [10, 10],
popupAnchor: [0,-20]
}),
other: L.icon({
iconUrl: '{% static "panorama/img/marker-circle-purple.png" %}',
iconSize: [20, 20],
iconAnchor: [10, 10],
popupAnchor: [0,-20]
}),
};
{% for pano in panoramas %}
{% if panorama.name != pano.name %}
var marker = L.marker([{{ pano.latitude }}, {{ pano.longitude }}], {icon: panoIcon, riseOnHover: true});
......@@ -93,9 +106,8 @@
{% endfor %}
var pointsOfInterest = L.layerGroup();
var poiOptions = {icon: poiIcon, riseOnHover: true};
{% for poi in poi_list %}
var marker = L.marker([{{ poi.latitude }}, {{ poi.longitude }}], poiOptions);
var marker = L.marker([{{ poi.latitude }}, {{ poi.longitude }}], {icon: poiIcons['{{ poi.kind }}'], riseOnHover: true});
var poiPopup = marker.bindPopup('{{ poi.name }}', {className : 'markerpopup', closeButton: false});
poiPopup.on('mouseover', marker.openPopup);
poiPopup.on('mouseout', marker.closePopup);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment