Skip to content

Instantly share code, notes, and snippets.

@joshuahouston
Last active August 29, 2015 14:23
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 joshuahouston/800cd59aab26c264f3bc to your computer and use it in GitHub Desktop.
Save joshuahouston/800cd59aab26c264f3bc to your computer and use it in GitHub Desktop.
Random Text Test
<!DOCTYPE html>
<html>
<head>
<script src='script.js'></script>
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<div id='map'></div>
<script>var map = L.map('map').setView([47.16, -115.316], 14);
// add an OpenStreetMap tile layer
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([47.16, -115.32]).on('click', bindNewPopup)
.addTo(map);
</script>
</body>
</html>
function randomText() {
var items = new Array(
"Ow",
"Stop poking me",
"Stop",
"Leave me alone",
"Don't you have anything better to do?",
"You're hurting me",
"Go away"
);
// Generates a random integer within the array index
var i = Math.floor(Math.random() * items.length);
return items[i];}
function bindNewPopup(){
this.bindPopup(randomText());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment