Created
October 25, 2013 03:09
-
-
Save geografa/7148908 to your computer and use it in GitHub Desktop.
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> | |
<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.556, -122.665], 12); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment