diff --git a/lostplaces/lostplaces_app/models.py b/lostplaces/lostplaces_app/models.py index 907f3bc..209c3b4 100644 --- a/lostplaces/lostplaces_app/models.py +++ b/lostplaces/lostplaces_app/models.py @@ -55,6 +55,19 @@ class Place (models.Model): longitude = models.FloatField() description = models.TextField() + # Get center position of all LP-geocoordinates. + + def average_latlon(): + place_list = Place.objects.all() + amount = len(place_list) + longitude = 0 + latitude = 0 + + for place in place_list: + longitude += place.longitude + latitude += place.latitude + return (latitude / amount, longitude / amount) + def __str__(self): return self.name diff --git a/lostplaces/lostplaces_app/templates/home.html b/lostplaces/lostplaces_app/templates/home.html index 40894a6..1e229d5 100644 --- a/lostplaces/lostplaces_app/templates/home.html +++ b/lostplaces/lostplaces_app/templates/home.html @@ -7,6 +7,7 @@