Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 82 lines (67 sloc) 1.93 KB
<!DOCTYPE html>
<html>
<script src="http://maps.google.com/maps/api/js"></script>
<script>
var map;
var markers = [];
function getFlickrData(){
var url = 'https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=4f145bca7bc87d6287f1caab430a29f9';
var tags = '&per_page=250';
tags += '&bbox=-71.097620,42.354970,-71.084316,42.363310';
tags += '&format=json';
tags += '&nojsoncallback=1';
tags += '&tags=mit';
tags += '&accuracy=6';
tags += '&extras=description,+date_taken,date_upload,owner_name,geo,url_s';
url = url + tags;
// make xhr request
var xhReq = new XMLHttpRequest();
xhReq.open('GET', url, false);
xhReq.send(null);
var serverResponse = xhReq.responseText;
// create object from response
var data = JSON.parse(serverResponse);
return data;
}
function init(){
var latlng = new google.maps.LatLng(42.359074, -71.091761);
var myOptions = {
zoom : 16,
center : latlng,
mapTypeId : google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map'), myOptions);
// get data, add markers and photos to page
var data = getFlickrData();
addMarkers();
}
// Adds markers to the map and into array
function addMarkers(){
// -------------------------------------------------
// YOUR CODE
// Loop through data.
// Add markers to map.
// -------------------------------------------------
}
function addMarker(photo){
var marker = new google.maps.Marker({
position: new google.maps.LatLng(photo.latitude,photo.longitude),
icon: {
path:google.maps.SymbolPath.CIRCLE,
fillColor: 'red',
fillOpacity: 0.5,
scale:7,
strokeWeight:1
},
map: map,
title: photo.title
});
markers.push(marker);
var image = '<img src="' + photo.url_s + '">';
document.getElementById('images').innerHTML += image;
}
window.onload = init;
</script>
<div id="map" style="width:1024px; height:768px"></div>
<div id="images"></div>
</html>
You can’t perform that action at this time.