Add the contact page, containing a map with the company location
I was not sure whether to use PostGIS to store the GPS location of the
company, as i am sure i will only use that point just to show the map.
However, just in case, it is not a big deal.
There is no way to change that from the administration pages for now,
because of time constraints, and it is very unlikely that they will
change the campgrounds’ location in the near future.
The location is in a separate table because i did not want to have to
change every test file, to be honest, but this also makes the map
“optional” without the need for NULL values.
I added the contact address to every public page because the new design
adds it to the footer, so i will be needing it everywhere, just like the
menu.
2023-10-06 19:21:00 +00:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: 2023 jordi fita mas <jordi@tandem.blog>
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
{{ define "title" -}}
|
|
|
|
{{( pgettext "Contact" "title" )}}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{ define "head" -}}
|
|
|
|
<link rel="stylesheet" href="/static/leaflet@1.9.4/leaflet.css">
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{ define "content" -}}
|
|
|
|
{{- /*gotype: dev.tandem.ws/tandem/camper/pkg/app.contactPage*/ -}}
|
|
|
|
<h2>{{( pgettext "Contact" "title" )}}</h2>
|
|
|
|
|
2023-10-06 20:02:59 +00:00
|
|
|
{{ template "companyAddress" .PublicPage.CompanyAddress }}
|
Add the contact page, containing a map with the company location
I was not sure whether to use PostGIS to store the GPS location of the
company, as i am sure i will only use that point just to show the map.
However, just in case, it is not a big deal.
There is no way to change that from the administration pages for now,
because of time constraints, and it is very unlikely that they will
change the campgrounds’ location in the near future.
The location is in a separate table because i did not want to have to
change every test file, to be honest, but this also makes the map
“optional” without the need for NULL values.
I added the contact address to every public page because the new design
adds it to the footer, so i will be needing it everywhere, just like the
menu.
2023-10-06 19:21:00 +00:00
|
|
|
<div id="map"></div>
|
|
|
|
|
|
|
|
{{ if .CompanyGeography -}}
|
|
|
|
<script src="/static/leaflet@1.9.4/leaflet.js"></script>
|
|
|
|
<script>
|
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
|
|
var container = document.getElementById("map");
|
|
|
|
container.style.height = '410px';
|
|
|
|
var map = L.map(container).setView(['{{ .CompanyGeography.Lat }}', '{{ .CompanyGeography.Lng }}'], '9');
|
|
|
|
|
|
|
|
L
|
|
|
|
.tileLayer('https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png', {
|
|
|
|
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, © <a href="https://carto.com/attributions">CARTO</a>'
|
|
|
|
})
|
|
|
|
.addTo(map)
|
|
|
|
;
|
|
|
|
|
|
|
|
map.scrollWheelZoom.disable();
|
|
|
|
|
|
|
|
var content =
|
|
|
|
{{- with .PublicPage.CompanyAddress -}}
|
|
|
|
'{{ .Address }}<br>{{ .City }} - {{ .PostalCode }}<br>{{ .Province }}'
|
|
|
|
{{- end -}}
|
|
|
|
;
|
|
|
|
L
|
|
|
|
.marker(['{{ .CompanyGeography.Lat }}', '{{ .CompanyGeography.Lng }}'])
|
|
|
|
.addTo(map)
|
|
|
|
.bindPopup(content)
|
|
|
|
;
|
|
|
|
|
|
|
|
var observer = ResizeObserver && new ResizeObserver(function () {
|
|
|
|
map.invalidateSize(true);
|
|
|
|
});
|
|
|
|
observer && observer.observe(container);
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|