Skip to content

Instantly share code, notes, and snippets.

@egardner
Forked from anonymous/index.html
Last active December 11, 2015 02:00
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 egardner/72c4f8cdfc87133f094f to your computer and use it in GitHub Desktop.
Save egardner/72c4f8cdfc87133f094f to your computer and use it in GitHub Desktop.
JS Bin[Leaflet extend test]// source http://jsbin.com/soperupuxu
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[add your bin description]">
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
#map {
height: 400px;
}
</style>
</head>
<body>
<div id="map">
</div>
<script id="jsbin-javascript">
var defaultOptions = {
center : [52.52, 13.42]
};
var opts = { zoom : 8 };
var initMap = function(opts){
// extend passed options with the default options#
// if we pass { zoom : 12 }, options would be { zoom : 12, center : [52.52, 13.42] }
var options = L.Util.extend(opts, defaultOptions);
// initialize map
var map = L.map('map').setView([51.505, -0.09], options.zoom);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
L.marker([51.5, -0.09]).addTo(map)
.bindPopup('A pretty CSS3 popup.<br> Easily customizable.')
.openPopup();
};
initMap(opts);
</script>
<script id="jsbin-source-css" type="text/css">#map {
height: 400px;
}</script>
<script id="jsbin-source-javascript" type="text/javascript">var defaultOptions = {
center : [52.52, 13.42]
};
var opts = { zoom : 8 };
var initMap = function(opts){
// extend passed options with the default options#
// if we pass { zoom : 12 }, options would be { zoom : 12, center : [52.52, 13.42] }
var options = L.Util.extend(opts, defaultOptions);
// initialize map
var map = L.map('map').setView([51.505, -0.09], options.zoom);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
L.marker([51.5, -0.09]).addTo(map)
.bindPopup('A pretty CSS3 popup.<br> Easily customizable.')
.openPopup();
};
initMap(opts);
</script></body>
</html>
#map {
height: 400px;
}
var defaultOptions = {
center : [52.52, 13.42]
};
var opts = { zoom : 8 };
var initMap = function(opts){
// extend passed options with the default options#
// if we pass { zoom : 12 }, options would be { zoom : 12, center : [52.52, 13.42] }
var options = L.Util.extend(opts, defaultOptions);
// initialize map
var map = L.map('map').setView([51.505, -0.09], options.zoom);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
L.marker([51.5, -0.09]).addTo(map)
.bindPopup('A pretty CSS3 popup.<br> Easily customizable.')
.openPopup();
};
initMap(opts);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment