Skip to content

Instantly share code, notes, and snippets.

@geografa
Created October 25, 2013 02:59
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 geografa/7148840 to your computer and use it in GitHub Desktop.
Save geografa/7148840 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title></title>
<script src='//api.tiles.mapbox.com/mapbox.js/v1.4.0/mapbox.js'></script>
<link href='//api.tiles.mapbox.com/mapbox.js/v1.4.0/mapbox.css' rel='stylesheet' />
<!--[if lte IE 8]>
<link href='//api.tiles.mapbox.com/mapbox.js/v1.4.0/mapbox.ie.css' rel='stylesheet'>
<![endif]-->
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
.tweetpic {width: 200px;}
</style>
</head>
<body>
<div id='map'></div>
<script type='text/javascript'>
var map = L.mapbox.map('map', 'examples.map-9ijuk24y');
var geoJson = [{
type: 'Feature',
"geometry": { "type": "Point", "coordinates": [-122.667, 45.556]},
"properties": {
"name": "maptimePDX",
"account": "maptimePDX",
"img": "https://pbs.twimg.com/media/BXY5tEFCQAEo03r.jpg"
}
}];
// Add custom popups to each using our custom feature properties
map.markerLayer.on('layeradd', function(e) {
var marker = e.layer,
feature = marker.feature;
// Create custom popup content
var popupContent = '<h2><a href="http://twitter.com/' + feature.properties.name + '">' +
feature.properties.name + '</a></h2>' +
'<img src ="' + feature.properties.img + '" class="tweetpic"/>'
'<p>(' + feature.properties.account + ') ';
// http://leafletjs.com/reference.html#popup
marker.bindPopup(popupContent,{
closeButton: false,
minWidth: 320
});
});
// Add features to the map
map.markerLayer.setGeoJSON(geoJson);
map.setView([45.908, -78.525], 4);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment