$.ajax({
url: "coords.json",
dataType: "json",
async: true,
success: function(msg){
google.maps.event.addDomListener(window, 'load', init);
function init() {
var mapOptions = {
zoom: 2,
center: new google.maps.LatLng(42, 10),
scrollwheel: false
};
var mapElement = document.getElementById('map');
var map = new google.maps.Map(mapElement, mapOptions);
setMarkers(map);
map.addListener('click', function() {
if (infowindow) {
infowindow.close();
}
});
}
function setMarkers(map) {
for (var n = 0; n < msg.length; n++) {
console.group('Path: '+n);
for (var i = 0; i < msg[n].length; i++) {
var m = i+1;
var mrk = msg[n][i];
var next_mrk = msg[n][m];
var marker = new google.maps.Marker({
position: {lat: mrk[1], lng: mrk[2]},
map: map,
icon: image,
title: mrk[0],
});
Message(marker, mrk[3]);
if(next_mrk) {
var dashedLine = new google.maps.Polyline({
path: [
{lat: mrk[1], lng: mrk[2]},
{lat: next_mrk[1], lng: next_mrk[2]}
],
strokeOpacity: 0,
icons: [{
icon: line,
offset: '0',
repeat: '6px'
}],
map: map
});
console.dirxml(mrk[0]+" - "+next_mrk[0]);
} else {
console.dirxml(msg[n][i][0]);
}
}
console.groupEnd();
}
}
function Message(marker, msg) {
var infowindow = new google.maps.InfoWindow({
content: msg
});
marker.addListener('mouseover', function() {
this.setIcon(image_hover); this.setZIndex(2);
infowindow.open(marker.get('map'), marker);
});
marker.addListener('mouseout', function() {
this.setIcon(image); this.setZIndex(1);
infowindow.close();
});
marker.addListener('click', function() {
marker.get('map').setZoom(6);
marker.get('map').setCenter(marker.getPosition());
});
}
}
});
$.ajax({
url: 'https://api.instagram.com/v1/users/' + userid + '/media/recent',
dataType: 'jsonp',
type: 'GET',
data: {client_id: clientid, count: count, access_token: 'xxxxxxxxxx'},
success: function(result){
for( x in result.data ){
// result.data[x].images.low_resolution.url - это URL картинки среднего разрешения, 306х306
// result.data[x].images.thumbnail.url - URL картинки 150х150
// result.data[x].images.standard_resolution.url - URL картинки 612х612
}
}
});