Skip to content

Instantly share code, notes, and snippets.

@tsamaya
Created November 30, 2015 14:41
Show Gist options
  • Save tsamaya/4cc6ca7f0129b93558cd to your computer and use it in GitHub Desktop.
Save tsamaya/4cc6ca7f0129b93558cd to your computer and use it in GitHub Desktop.
leaflet introduction - demo 2
<!DOCTYPE html>
<html>
<head>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />
<style type="text/css">
body {
padding: 0;
margin: 0;
}
#map { height: 350px; }
html, body {
height: 100%;
}
</style>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.css" />
</head>
<body>
<div id="map"></div>
<script src="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.js"></script>
<script>
var map = L.map('map').setView([45.18478, 5.73134], 13);
L.tileLayer('http://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', {
maxZoom: 15,
attribution: 'Map data: &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, <a href="http://viewfinderpanoramas.org">SRTM</a> | Map style: &copy; <a href="https://opentopomap.org">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>)'
}).addTo(map);
var popup = L.popup();
function onMapClick(e) {
popup
.setLatLng(e.latlng)
.setContent("Vous avez cliqué sur la carte : " + e.latlng.toString())
.openOn(map);
}
map.on('click', onMapClick);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment