Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@psanxiao
Created October 6, 2014 16:20
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 psanxiao/ac1ccc30340be81e914c to your computer and use it in GitHub Desktop.
Save psanxiao/ac1ccc30340be81e914c to your computer and use it in GitHub Desktop.
Instagram photos map
<div id="map"></div>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script src="./Leaflet.Instagram/examples/lib/fancybox/jquery.fancybox.pack.js"></script>
<script src="./Leaflet.Instagram/examples/lib/reqwest.min.js"></script>
<script src="./Leaflet.Instagram/examples/lib/leaflet/leaflet.js"></script>
<script src="./Leaflet.Instagram/examples/lib/cluster/leaflet.markercluster.js"></script>
<script src="./Leaflet.Instagram/dist/Leaflet.Instagram.Fancybox.Cluster.js"></script>
<script>
var map = L.map('map').setView([40.47, -3.75], 5);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
$.ajax({
type: "GET",
dataType: "jsonp",
cache: false,
url: "https://api.instagram.com/v1/users/YOUR_USER_ID_HERE?access_token=YOUR_INSTAGRAM_TOKEN_HERE",
success: function (data) {
var url = 'https://api.instagram.com/v1/users/YOUR_USER_ID_HERE/media/recent?access_token=YOUR_INSTAGRAM_TOKEN_HERE&count=' + data.data.counts.media;
L.instagram.cluster(url, {
featureGroup: L.instagram.fancybox
}
).addTo(map);
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment