refactor: add map marker to context on update

This commit is contained in:
James Graham
2021-01-15 16:32:57 +00:00
parent 9db870bcb0
commit 59f717829a
4 changed files with 31 additions and 36 deletions

View File

@@ -2,27 +2,12 @@
{% block extra_head %}
{% load staticfiles %}
<script type="application/javascript">
const data = [
{
name: '{{ organisation.name }}',
lat: '{{ organisation.latitude }}',
lng: '{{ organisation.longitude }}'
},
]
const settings = {
zoom: 2,
centre_lat: '{{ organisation.latitude }}',
centre_lng: '{{ organisation.longitude }}',
}
</script>
<!-- {{ map_markers|json_script:'map-markers' }} -->
{{ map_markers|json_script:'map-markers' }}
<script src="{% static 'js/map.js' %}"></script>
<script src="{% static 'js/location_picker.js' %}"></script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key={{ settings.GOOGLE_MAPS_API_KEY }}&callback=initMap&libraries=places"
<script async defer src="https://maps.googleapis.com/maps/api/js?key={{ settings.GOOGLE_MAPS_API_KEY }}&callback=initPicker&libraries=places"
type="text/javascript"></script>
{% endblock %}

View File

@@ -2,25 +2,12 @@
{% block extra_head %}
{% load staticfiles %}
<script type="application/javascript">
const data = [
{
name: '{{ person.name }}',
lat: '{{ answer_set.latitude }}',
lng: '{{ answer_set.longitude }}'
},
]
const settings = {
zoom: 2,
centre_lat: '{{ answer_set.latitude }}',
centre_lng: '{{ answer_set.longitude }}',
}
</script>
{{ map_markers|json_script:'map-markers' }}
<script src="{% static 'js/map.js' %}"></script>
<script src="{% static 'js/location_picker.js' %}"></script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key={{ settings.GOOGLE_MAPS_API_KEY }}&callback=initMap&libraries=places"
<script async defer src="https://maps.googleapis.com/maps/api/js?key={{ settings.GOOGLE_MAPS_API_KEY }}&callback=initPicker&libraries=places"
type="text/javascript"></script>
{% endblock %}