我正在尝试在地图上放置标记。我想通过所有的纬度 和经度从地图上查看和绘制,但不知道怎么做。
views.py
def map(request, template_name='map.html'):
all_objects = NewRegistrationModel.objects.all()
return render_to_response(template_name, {'lon':all_objects})
map.html
<div class="col-md-12">
<div id="map-canvas" style="margin-left:10;width:100%;min-height:500px;">
</div>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var map = L.map('map-canvas').setView([28.41752832637288,84.13003176934866], 7);
L.tileLayer('http://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}',{
maxZoom: 10,
subdomains:['mt0','mt1','mt2','mt3']
}).addTo(map);
{% for mark in lon %}
L.marker( [{{mark.latitude }}, {{ mark.longitude }}] )
.addTo( map );
{% endfor %}
</script>