Code to create a simple map with Leaflet
Last active
August 29, 2015 14:04
-
-
Save wjdennen/b55c93d14d0d5aed30ee to your computer and use it in GitHub Desktop.
Simple Leaflet map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$( document ).ready(function() { | |
var map = L.map('map', { | |
center: [30, 0], | |
zoom: 2, | |
minZoom: 2, | |
maxZoom: 5, | |
zoomControl: false, | |
attributionControl: false, | |
doubleClickZoom: true, | |
scrollWheelZoom: false | |
}); | |
L.tileLayer('http://brown.edu/web/bill/tileserver/files/{z}/{x}/{y}.png', { | |
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>', | |
maxZoom: 5, | |
noWrap: true, | |
}).addTo(map); | |
new L.Control.Zoom({ position: 'bottomright' }).addTo(map); | |
// Internally this function uses the TopoJSON library to decode the given file | |
// into GeoJSON. | |
var continentLayer = omnivore.topojson('continents.topo.json') | |
.addTo(map); | |
console.log( "ready now!" ); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>A Simple Leaflet Map</title> | |
<script src="//d3js.org/d3.v3.min.js"></script> | |
<script src="//d3js.org/topojson.v1.min.js"></script> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> | |
<script src='//api.tiles.mapbox.com/mapbox.js/v1.6.4/mapbox.js'></script> | |
<link href='//api.tiles.mapbox.com/mapbox.js/v1.6.4/mapbox.css' rel='stylesheet' /> | |
<!-- added 20140806 --> | |
<script src='//api.tiles.mapbox.com/mapbox.js/plugins/leaflet-omnivore/v0.1.2/leaflet-omnivore.min.js'></script> | |
<script src="base.js"></script> | |
<style>#map { height: 700px; }</style> | |
</head> | |
<body> | |
<div id="map"></div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#map { height: 500px; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment