Skip to content

Instantly share code, notes, and snippets.

@nonZero
Created November 11, 2015 09:22
Show Gist options
  • Save nonZero/7a036c3226a27dd8e266 to your computer and use it in GitHub Desktop.
Save nonZero/7a036c3226a27dd8e266 to your computer and use it in GitHub Desktop.
display points as leaflet markers
{% load staticfiles %}
<!doctype html>
<style>
#map {
height: 500px;
}
</style>
cool!
<link rel="stylesheet" href="{% static "leaflet/leaflet.css" %}"/>
<script src="{% static "leaflet/leaflet-src.js" %}"></script>
<div id="map"></div>
<script>
console.log("start");
var map = L.map('map').setView([{{ points.0.coords.1 }}, {{ points.0.coords.0 }}], 13);
var points = [];
{% for p in points %}
points.push(L.marker([{{ p.coords.1 }}, {{ p.coords.0 }}]));
{% endfor %}
var fg = L.featureGroup(points).addTo(map);
map.fitBounds(fg.getBounds());
L.tileLayer('http://maptile.maps.svc.ovi.com/maptiler/maptile/newest/satellite.day/{z}/{x}/{y}/256/png8', {}).addTo(map);
console.log(map);
console.log("end");
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment