我的代碼在傳單圖上沒有顯示標記所有的時間。我的代碼如下。代碼下面是我看到的「查看源代碼」。正如你所看到的,標記是用我的代碼中的位置創建的,但不會顯示在地圖上。有任何想法嗎?leaflet.js標記沒有顯示
我的網站在這裏,如果您查看源代碼,您可以看到我們正在嘗試製作標記。 https://pursuer.herokuapp.com/maps/
{% load leaflet_tags %}
<head>
{% leaflet_js %}
{% leaflet_css %}
<style>
.leaflet-container { /* all maps */
width: 600px;
height: 400px;
}
#yourmap {
width: 1600px;
height: 700px;
}
#sidebar{
float: right;
}
</style>
</head>
<body>
<div id="sidebar">
{% block sidebar %}
<ul>
<li><a href="/">Home</a></li>
<li><a href="/register">Register</a></li>
<li><a href="/accounts/login/">Login</a></li>
<li><a href="/setup/">Setup Your Device</a></li>
</ul>
{% endblock %}
</div>
{% if user.is_authenticated %}
<p>Welcome, {{ user.username }}. Thanks for logging in.</p>
{% else %}
<p>Welcome, new user. Please log in.</p>
{% endif %}
{% if latest_device_list %}
<script type="text/javascript">
var userArray = new Array();
function map_init_basic (yourmap, options) {
var marker = null;
// map.setView([26.2406685,-80.1665045], 12);
//map.locate({setView:true, maxZoom: 8});
{% for device in latest_device_list %}
var popupText = null;
{% if user_imei.User_Alias %}
popupText='{{user_imei.User_Alias}}';
{% else %}
popupText = {{device.Device_IMEI}};
{% endif %}
marker = new L.marker([{{device.Device_Lat}}, {{device.Device_Lon}}])
.bindPopup("<h3>"+popupText+"</h3>")
.addTo(yourmap);
user = {{device.Device_IMEI}};
userArray[user] = marker;
{% endfor %}
}
function update_position()
{
{% for device in latest_device_list %}
var popupText = null;
popupText = {{device.Device_IMEI}};
userArray[{{device.Device_IMEI}}].setLatLng(new L.LatLng([{{device.Device_Lat}}, {{device.Device_Lon}}]))
.bindPopup("<h3>"+popupText+</h3>")
.update();
{% endfor %}
// pan to last device location
yourmap.panTo(new L.LatLng(marker.getLatLng()),yourmap.getZoom());
window.setTimeout(update_position,50);
}
update_position();
</script>
{% else %}
<p>No Devices are available.</p>
{% endif %}
{% leaflet_map "yourmap" callback="window.map_init_basic" %}
</body>
謝謝你,似乎是這個問題! – user3470096