Skip to content

Instantly share code, notes, and snippets.

@Realetive
Created August 20, 2016 10:28
Show Gist options
  • Save Realetive/63649fd9c7bbd3c0460931b537f6e1a2 to your computer and use it in GitHub Desktop.
Save Realetive/63649fd9c7bbd3c0460931b537f6e1a2 to your computer and use it in GitHub Desktop.
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="mozgoboj-map.js"></script>
<style>
#google-map {
height: 500px;
width: 100%;
}
</style>
</head>
<body>
<div id="google-map"></div>
<script type="text/javascript" src="https://maps.google.com/maps/api/js?callback=myMap" async defer></script>
</body>
</html>
function myMap() {
var styleArray = [{
featureType: "water",
stylers: [
{ visibility: "on" },
{ weight: 0.1 },
{ invert_lightness: true },
{ color: "#b64a96" }
]
},{
featureType: "administrative.locality",
stylers: [
{ color: "#ffffff" },
{ weight: 0.1 },
{ visibility: "simplified" }
]
},{
elementType: "labels.text",
stylers: [
{ color: "#ffffff" },
{ weight: 0.1 },
{ visibility: "simplified" }
]
},{
featureType: "landscape",
stylers: [
{ color: "#382042" }
]
},{
featureType: "road",
stylers: [
{ visibility: "off" }
]
},{
featureType: "poi",
stylers: [
{ visibility: "off" }
]
},{
featureType: "transit",
stylers: [
{ visibility: "off" }
]
},{
featureType: "administrative.country",
stylers: [
{ color: "#ffffff" },
{ visibility: "on" },
{ weight: 0.3 }
]
}];
var styledMap = new google.maps.StyledMapType( styleArray, { name: "Styled Map" } );
var mapOptions = {
center: { lat: 55.291, lng: 27.404 },
scrollwheel: false,
zoom:5,
// mapTypeControlOptions: {
// mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'map_style']
// }
}
var map = new google.maps.Map(document.getElementById('google-map'),mapOptions);
map.mapTypes.set('google-map', styledMap);
map.setMapTypeId('google-map');
var cities = [
{ coords: [ 53.900, 27.557 ], title: 'в Minsk' }
, { coords: [ 52.098, 23.673 ], title: 'в Brest' }
, { coords: [ 52.425, 31.009 ], title: 'в Gomel' }
, { coords: [ 53.678, 23.836 ], title: 'в Grodno' }
, { coords: [ 53.896, 30.337 ], title: 'в Mogilev' }
, { coords: [ 53.128, 26.008 ], title: 'в Baranovichi' }
, { coords: [ 53.136, 29.222 ], title: 'в Bobruisk' }
, { coords: [ 54.215, 28.515 ], title: 'в Borisov' }
, { coords: [ 52.212, 24.361 ], title: 'в Kobrin' }
, { coords: [ 53.896, 25.300 ], title: 'в Lida' , link: 'https://vk.com/realetive' }
, { coords: [ 54.314, 26.850 ], title: 'в Molodechno' }
, { coords: [ 54.503, 30.410 ], title: 'в Orsha' }
, { coords: [ 52.789, 27.529 ], title: 'в Soligorsk' }
, { coords: [ 52.124, 26.075 ], title: 'в Pinsk' }
, { coords: [ 57.044, 53.979 ], title: 'в Votkinsk' }
, { coords: [ 56.835, 60.610 ], title: 'в Ekaterinburg' }
, { coords: [ 56.852, 53.220 ], title: 'в Ijevsk' }
, { coords: [ 54.703, 20.504 ], title: 'в Kaliningrad' }
, { coords: [ 45.052, 38.976 ], title: 'в Krasnodar' }
, { coords: [ 51.707, 36.156 ], title: 'в Kursk' }
, { coords: [ 56.313, 43.915 ], title: 'в Nnovgorod' , link: 'https://vk.com/brazzers' }
, { coords: [ 58.011, 56.280 ], title: 'в Perm' }
, { coords: [ 55.431, 37.555 ], title: 'в Podolsk' }
, { coords: [ 47.215, 39.704 ], title: 'в Rostov' }
, { coords: [ 53.237, 50.240 ], title: 'в Samara' }
, { coords: [ 59.908, 30.306 ], title: 'в Petersburg' }
, { coords: [ 54.783, 32.067 ], title: 'в Smolensk' }
, { coords: [ 56.854, 35.906 ], title: 'в Tver' }
, { coords: [ 53.523, 49.427 ], title: 'в Tolyatti' }
, { coords: [ 57.152, 65.541 ], title: 'в Tyumen' }
, { coords: [ 56.774, 54.137 ], title: 'в Chaikovskiy' }
, { coords: [ 52.524, 13.409 ], title: 'в Berlin' , link: 'https://vk.com/durov' }
, { coords: [ 48.148, 11.569 ], title: 'в Munich' }
, { coords: [ 55.750, 37.621 ], title: 'в Moscow' }
, { coords: [ 55.194, 30.200 ], title: 'в Vitebsk' }
]
var marker, infowindow = new google.maps.InfoWindow({
maxWidth: 160
});
for (var i = 0; i < cities.length; i++) {
marker = new google.maps.Marker({
position: { lat: cities[i].coords[0], lng: cities[i].coords[1] },
map: map,
title: 'Мозгобойня ' + cities[i].title
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
var content = ['<div style="width: 300px;">',
'<h4>МозгоБойня ' + cities[i].title + '</h4>',
'<p>',
'<a href="' + (cities[i].link ? cities[i].link : 'https://vk.com/mozgoboj' ) + '">',
'Узнать всю информацию',
'</a>',
'</p>',
'</div>'].join('');
infowindow.setContent(content);
infowindow.open(map, marker);
}
})(marker, i));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment