Skip to content

Instantly share code, notes, and snippets.

@tstibbs
Last active June 13, 2016 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tstibbs/c07574f89c0e47b9b3d2ec7df8c7e0c9 to your computer and use it in GitHub Desktop.
Save tstibbs/c07574f89c0e47b9b3d2ec7df8c7e0c9 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<!-- Based off https://github.com/xguaita/Leaflet.MapCenterCoord/blob/1211f46947c0f375a717561b9230c8303a178062/examples/simple.html -->
<html>
<head>
<title>Center Position Control - Simple</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.css" />
<link rel="stylesheet" href="http://xguaita.github.io/Leaflet.MapCenterCoord/dist/L.Control.MapCenterCoord.min.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.js"></script>
<script src="http://xguaita.github.io/Leaflet.MapCenterCoord/dist/L.Control.MapCenterCoord.min.js"></script>
<style>
body {
padding: 0;
margin: 0;
}
html, body, #map {
height: 100%;
}
</style>
</head>
<body>
<div id="map" class="map"></div>
<script>
var map = L.map('map').setView([39.588, 2.935], 9);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
var marker = L.marker([39.588, 2.935]).addTo(map);
L.control.mapCenterCoord().addTo(map);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment