From 1123d655bd6708fba056d9800af61e9f2e8bd6eb Mon Sep 17 00:00:00 2001 From: lxf Date: Sun, 2 Jan 2022 14:30:04 -0500 Subject: loc: made walks display track on map --- app/locations/models.py | 10 ++++ .../templates/locations/track_detail.html | 70 +++++++++++++++++++++- app/utils/static/image-loader.js | 6 +- 3 files changed, 84 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/locations/models.py b/app/locations/models.py index e27e6cc..9580132 100644 --- a/app/locations/models.py +++ b/app/locations/models.py @@ -499,6 +499,16 @@ class Track(models.Model): def get_rating(self): return int(self.rating) + + @property + def lon(self): + '''Get the site's longitude.''' + return self.point.x + + @property + def lat(self): + '''Get the site's latitude.''' + return self.point.y @property def ratings_range(cls): diff --git a/app/locations/templates/locations/track_detail.html b/app/locations/templates/locations/track_detail.html index 6339852..df71d94 100644 --- a/app/locations/templates/locations/track_detail.html +++ b/app/locations/templates/locations/track_detail.html @@ -1,5 +1,7 @@ {% extends 'base.html' %} {% load typogrify_tags %} +{% block extrahead %} +{% endblock %} {%block bodyid%}class="detail"{%endblock%} {% block breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{% endblock %} {% block primary %} @@ -21,7 +23,7 @@
- {{object.title}} map +
+{{ object.gpx_file.raw_data|json_script:"track" }} +{% endblock %} +{% block js %} + + + {% endblock %} +{% comment %} + + + +{{ object.gpx_file.raw_data|json_script:"track" }} + +{% endcomment %} diff --git a/app/utils/static/image-loader.js b/app/utils/static/image-loader.js index 707c1c5..5a5b3b4 100644 --- a/app/utils/static/image-loader.js +++ b/app/utils/static/image-loader.js @@ -41,7 +41,11 @@ function add_images(){ } document.addEventListener("DOMContentLoaded", function(event) { add_images(); - md = document.forms["post_form"].elements["body_markdown"]; + if (document.forms["post_form"]) { + md = document.forms["post_form"].elements["body_markdown"]; + } else { + md = document.forms["track_form"].elements["body_markdown"]; + } md.style.maxHeight = "300rem"; md.style.maxWidth = "300rem"; }); -- cgit v1.2.3-70-g09d2