jQuery(function($) { "use strict"; // Asynchronously Load the map API var script = document.createElement('script'); script.src = "http://maps.googleapis.com/maps/api/js?sensor=false&callback=initialize"; document.body.appendChild(script); }); function initialize() { var map; var bounds = new google.maps.LatLngBounds(); var mapOptions = { mapTypeId: 'hybrid', scrollwheel: false }; // Display a map on the page map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); map.setTilt(45); // Multiple Markers var markers = [ [ 'Торревьеха', 37.971182710488435,-0.6832122802734375, { modal: '
' + '' + '

Торревьеха

' + '

' + '
' } ],[ 'Мыс Горн', -55.97014787085833,-67.27169036865234, { modal: '
' + '' + '

Мыс Горн

' + '

' + '
' } ],[ 'Мартиника', 14.578267209240462,-61.03179931640625, { modal: '
' + '' + '

Мартиника

' + '

' + '
' } ],[ 'Канары', 27.994401411046145,-16.5948486328125, { modal: '
' + '' + '

Канары

' + '

' + '
' } ],[ 'Сицилия', 38.10862766432127,13.392333984375, { modal: '
' + '' + '

Сицилия

' + '

' + '
' } ],[ 'Бонифачо', 41.30257109430557,9.25048828125, { modal: '
' + '' + '

Бонифачо

' + '

' + '
' } ],[ 'Генуя', 44.39454219215589,8.931884765625, { modal: '
' + '' + '

Генуя

' + '

' + '
' } ],[ 'Родос', 36.421282443649496,28.21563720703125, { modal: '
' + '' + '

Родос

' + '

' + '
' } ],[ 'Санкт-Петербург', 59.91648345450877,30.146484375, { modal: '
' + '' + '

Санкт-Петербург

' + '

' + '
' } ],[ 'Хельсинки', 60.15790959006859,24.949951171875, { modal: '
' + '' + '

Хельсинки

' + '

' + '
' } ],[ 'Клайпеда', 55.677584411089526,21.060791015625, { modal: '
' + '' + '

Клайпеда

' + '

' + '
' } ],[ 'Киль', 54.34535094489876,10.1568603515625, { modal: '
' + '' + '

Киль

' + '

' + '
' } ],[ 'Кале', 50.97399437028297,1.85394287109375, { modal: '
' + '' + '

Кале

' + '

' + '
' } ],[ 'Сен-Мало', 48.636538782610494,-2.054443359375, { modal: '
' + '' + '

Сен-Мало

' + '

' + '
' } ],[ 'Квебек', 47.05515408550348,-70.64208984375, { modal: '
' + '' + '

Квебек

' + '

' + '
' } ],[ 'Гибралтар', 36.01356058518153,-5.47119140625, { modal: '
' + '' + '

Гибралтар

' + '

' + '
' } ],[ 'Рим', 41.77336007442076,12.20855712890625, { modal: '
' + '' + '

Рим

' + '

' + '
' } ],[ 'Пиза', 43.678239078242115,10.271873474121094, { modal: '
' + '' + '

Пиза

' + '

' + '
' } ],[ 'Ибица', 38.89530825492018,1.439208984375, { modal: '
' + '' + '

Ибица

' + '

' + '
' } ],[ 'Майорка', 39.78954439311164,3.15032958984375, { modal: '
' + '' + '

Майорка

' + '

' + '
' } ],[ 'Ля Маддалена', 41.21380381870091,9.40981149673462, { modal: '
' + '' + '

Ля Маддалена

' + '

' + '
' } ],[ 'Лиссабон', 38.634036452919226,-9.25048828125, { modal: '
' + '' + '

Лиссабон

' + '

' + '
' } ],[ 'Брест', 48.37632112598019,-4.486541748046875, { modal: '
' + '' + '

Брест

' + '

' + '
' } ],[ 'Остров Нерва', 60.245702,27.956452, { modal: '
' + '' + '

Остров Нерва

' + '

' + '
' } ],[ 'Кронштадт', 59.98250201795759,29.7674560546875, { modal: '
' + '' + '

Кронштадт

' + '

' + '
' } ],[ 'Выборг', 60.714098581481025,28.727703094482422, { modal: '
' + '' + '

Выборг

' + '

' + '
' } ],[ 'Лаппеенранта', 61.064681138791826,28.192462921142578, { modal: '
' + '' + '

Лаппеенранта

' + '

' + '
' } ],[ 'Турку', 60.42469913713462,22.17041015625, { modal: '
' + '' + '

Турку

' + '

' + '
' } ] ]; // Display multiple markers on a map var infoWindow = new google.maps.InfoWindow(), marker, i; // Loop through our array of markers & place each one on the map for( i = 0; i < markers.length; i++ ) { var position = new google.maps.LatLng(markers[i][1], markers[i][2]); bounds.extend(position); marker = new google.maps.Marker({ position: position, map: map, title: markers[i][0] }); // Allow each marker to have an info window google.maps.event.addListener(marker, 'click', (function(marker, i) { return function() { infoWindow.setContent(markers[i][3].modal); infoWindow.open(map, marker); } })(marker, i)); // Automatically center the map fitting all markers on the screen map.fitBounds(bounds); }; // Override our map zoom level once our fitBounds function runs (Make sure it only runs once) var boundsListener = google.maps.event.addListener((map), 'tilesloaded', function(event) { this.setZoom(this.getZoom()-0); google.maps.event.removeListener(boundsListener); }); }