我添加了一个 django-leaflet 地图来显示地点标记。我无法将标记显示为点击事件并将它们发送到 postgres/postgis 数据库。我使用 django-leaflet 表单来输入数据。我想知道如何显示位置标记并将它们与其他模型字段一起发送到后端。
{% load static %}
{% include 'base.html' %}
{% load leaflet_tags %}
<style>
.leaflet-container { /* all maps */
width: 1400px;
height: 800px;
align-content: right;
}
</style>
<html>
<head>
{% leaflet_js plugins="forms" %}
{% leaflet_css plugins="forms" %}
</head>
<body>
{% leaflet_map "map" callback="window.map_init_basic" %}
<h2>Edit Apartment ID {{ Apartment.apt_id }}</h2>
<h2>Edit Apartment Location {{ Apartment.location }}</h2>
<form action="POST">
{{ form }}
<input type="submit"/>
</form>
</body>
</html>
<script type="text/javascript">
window.addEventListener("map:init", function (e) {
var detail = e.detail;
L.marker([38.7578, 8.9806]).addTo(detail.map);
}, false);
</script>