1// When the window has finished loading create our google map below 2//google.maps.event.addDomListener(window, 'load', Gmaps_init); 3 4/*$(document).ready(function () { 5 Gmaps_init(); 6});*/ 7 8var mapaNacitana = false; // Ak je true, mapa je uz nacitana a uz ju netreba znovu nacitavat 9var map = null; // Objekt mapy 10var geocoder = null; // Objekt geocodera ktory prevadza adresy na LAT, LON 11var zoznamHladiskAsync = new Array(); // Zoznam hladisk pre ktore budeme asynchronne hladat polohu 12var infoWindowOpened = null; // Ukazovatel na informacne okno na mape ktore je prave otvorene 13var zoznamMarkerov = new Array(); // Zoznam vsetkych znaciek na mape 14 15 16function Gmaps_init() { 17 18 if (mapaNacitana == true) 19 return; 20 21 mapaNacitana = true; 22 23 // Basic options for a simple Google Map 24 // For more options see: https://developers.google.com/maps/documentation/javascript/reference#MapOptions 25 26 var _lat = 48.1458923; 27 var _lon = 17.1071373; 28 29 if (lokalita == 'cz') { _lon = 14.4378005, _lat = 50.0755381; } 30 31 // mapmarker 32 var mapOptions = { 33 // How zoomed in you want the map to start at (always required) 34 zoom: 11, 35 scrollwheel: false, 36 // The latitude and longitude to center the map (always required) 37 center: new google.maps.LatLng(_lat, _lon), // Bratislava 38 scaleControl: true, 39 // How you would like to style the map. 40 // This is where you would paste any style found on Snazzy Maps. 41 styles: [{ "featureType": "all", "stylers": [{ "saturation": 0 }, { "hue": "#e7ecf0" }] }, { "featureType": "road", "stylers": [{ "saturation": -70 }] }, { "featureType": "transit", "stylers": [{ "visibility": "off" }] }, { "featureType": "poi", "stylers": [{ "visibility": "off" }] }, { "featureType": "water", "stylers": [{ "visibility": "simplified" }, { "saturation": -60 }] }] 42 }; 43 // Get the HTML DOM element that will contain your map 44 // We are using a div with id="map" seen below in the <body> 45 var mapElement = document.getElementById('map-canvas'); 46 47 // Create the Google Map using out element and options defined above 48 map = new google.maps.Map(mapElement, mapOptions); 49 geocoder = new google.maps.Geocoder(); 50 51 52 // Ked klikne na mapu, tak povolime zoomivanie koleckom 53 google.maps.event.addListener(map, 'click', function (event) { 54 this.setOptions({ scrollwheel: true }); 55 }); 56 57 // ked klikne mimo tak zakazeme 58 $(document).click(function (evt) { 59 var target = $(evt.target); 60 var isMap = false; 61 62 while (true) { 63 if (target.attr('id') == "map-canvas") { 64 isMap = true; 65 break; 66 } 67 if (target[0] == document) 68 break; 69 70 target = target.parent(); 71 72 if(target.length == 0) 73 return; 74 } 75 76 if (isMap == false) 77 map.setOptions({ scrollwheel: false }); 78 }); 79 80 google.maps.event.addListener(map, 'zoom_changed', function () { 81 //document.getElementById('map-canvas-zoom').innerHTML = map.zoom; 82 // 3 seconds after the center of the map has changed, pan back to the 83 // marker. 84 //window.setTimeout(function () { 85 // map.panTo(marker.getPosition()); 86 //}, 3000); 87 }); 88 89 var zoznamHladisk = new Array(); // Sem si ulozime vsetky hladiska pre toto podujatie resp. NPodujatie 90 var zhpocet = 0; 91 92 for (var i in ID_Predstavenie) { 93 if (ID_Predstavenie.hasOwnProperty(i)) { 94 var id_predstavenie = ID_Predstavenie[i]; 95 var predstavenie = dic_predstavenie[id_predstavenie]; 96 97 if (!(typeof (zoznamHladisk[predstavenie.hladisko.id]) != 'undefined' && zoznamHladisk[predstavenie.hladisko.id] != null)) { 98 if (isVenue) { 99 if (VenueID == predstavenie.hladisko.id) 100 { 101 zoznamHladisk[predstavenie.hladisko.id] = predstavenie.hladisko; 102 zhpocet++; 103 } 104 } 105 else { 106 zoznamHladisk[predstavenie.hladisko.id] = predstavenie.hladisko; 107 zhpocet++; 108 } 109 } 110 } 111 } 112 113 if (zhpocet == 0) 114 return; 115 116 for (var id_hladisko in zoznamHladisk) { 117 if (zoznamHladisk.hasOwnProperty(id_hladisko)) { 118 var hladisko = zoznamHladisk[id_hladisko]; 119 120 if (!(hladisko.LAT != null && hladisko.LON != null)) // O hladisku este nemame info, ze kde su jeho zemepisne suradnice, pokusime sa ich zistit pomocou Geocoding API 121 { 122 zoznamHladiskAsync.push(hladisko); // Zapiseme si zoznam hladisk, ktore budeme zistovat asynchronne 123 } 124 else { 125 showMarker(hladisko); // Tie o ktorych vieme kde su, vykreslime okamzite 126 } 127 } 128 } 129 130 if (zoznamHladiskAsync.length != 0) 131 Gmaps_async_step(); // Spustime async zistovanie a vykreslovanie tych o ktorych nevieme polohu 132 else { 133 //google.maps.event.addListener(map, "resize", function () { 134 // centruj(zoznamMarkerov); 135 //}); 136 setTimeout("centruj(zoznamMarkerov);
136", 100); 137 } 138} 139 140// Asynchronne budeme zistovat pozicie na zaklade adries 141var hladisko_zahajene = null; 142 143function Gmaps_async_step() { 144 145 if (zoznamHladiskAsync.length != 0) { // Je co zistovat 146 if (hladisko_zahajene == null) { // Aktualne sa nic nezistuje 147 hladisko_zahajene = zoznamHladiskAsync.pop(); 148 codeAddress(hladisko_zahajene); 149 } 150 setTimeout("Gmaps_async_step();", 500); // Dalsie hladisko zistime po 500 ms 151 } 152 else { // Skoncili sme, zacentrujeme mapu 153 centruj(zoznamMarkerov); 154 } 155} 156 157function codeAddress(hladisko) { 158 159 var address = hladisko.nazov + (hladisko.adresa != null && hladisko.adresa.length > 3 ? (',' + hladisko.adresa) : '') + ',' + hladisko.mesto.nazov; 160 161 geocoder.geocode({ 162 'address': address 163 }, function (results, status) { 164 if (status == google.maps.GeocoderStatus.OK) { 165 166 var LAT = results[0].geometry.location.lat(); 167 var LON = results[0].geometry.location.lng(); 168 169 hladisko_zahajene.LAT = LAT; 170 hladisko_zahajene.LON = LON; 171 showMarker(hladisko_zahajene); 172 173 //map.setCenter(results[0].geometry.location); 174 //var marker = new google.maps.Marker({ 175 // map: map, 176 // position: results[0].geometry.location 177 //}); 178 //return results; 179 //alert(result); 180 181 182 // Vlozime miesta do kosika 183 $.ajax({
184 url: absoluteUri + "Event/GmapsSet/" + hladisko_zahajene.id + "/" + hladisko_zahajene.LAT + "/" + hladisko_zahajene.LON, 185 dataType: "json", 186 cache: false, 187 statusCode: { 188 404: function () { alert('Page not found.'); }, 189 500: function () { alert('Internal server error.'); } 190 } 191 }).done(function (data) { 192 }); 193 194 hladisko_zahajene = null; 195 196 } else { 197 //alert('Geocode was not successful for the following reason: ' + status); 198 199 $.ajax({ 200 url: absoluteUri + "Event/GmapsSet/" + hladisko_zahajene.id + "/0/0", 201 dataType: "json", 202 cache: false, 203 statusCode: { 204 404: function () { alert('Page not found.'); }, 205 500: function () { alert('Internal server error.'); } 206 } 207 }).done(function (data) { 208 }); 209 210 hladisko_zahajene = null; 211 } 212 }); 213} 214 215function showMarker(hladisko) { 216 var marker = new google.maps.Marker({ 217 position: new google.maps.LatLng(hladisko.LAT, hladisko.LON), 218 map: map, 219 animation: google.maps.Animation.DROP, 220 title: hladisko.nazov 221 }); 222 223 marker["Hladisko_id"] = hladisko.id; 224 zoznamMarkerov.push(marker); 225 226 227 google.maps.event.addListener(marker, 'click', function () { 228 229 map.setOptions({ scrollwheel: true }); 230 231 var hladisko = dic_hladisko[this.Hladisko_id]; 232 var infowindow = null; 233 234 if (typeof (hladisko.infowindow) != "undefined" && hladisko.infowindow != null) { 235 infowindow = hladisko.infowindow; 236 } 237 else { 238 239 var content = "<div style='margin:10px'>"; 240 content += "<span style='font-size:12px; font-weight:bold'>" + hladisko.nazov + "</span>"; 241 242 if(isVenue == false) 243 content += " <a href='" + absoluteUri + "Venue/" + hladisko.id + (window.location.href.indexOf("iframe") != -1 ? "?iframe" : "") + "'>" + lang["btnDetail"] + "</a>" 244 content += "<br/>"; 245 246 if (lokalita == "empik") 247 content += "<span style='font-weight:bold'>" + lang["Adresa"] + ": </span><span>" + hladisko.adresa + ", " + hladisko.mesto.nazov + "</span><br/>"; 248 else 249 content += "<span style='font-weight:bold'>" + lang["Adresa"] + ": </span><span>" + hladisko.adresa + ", " + hladisko.psc + " " + hladisko.mesto.nazov + "</span><br/>"; 250 251 if (hladisko.www != null && hladisko.www.length > 3) 252 content += "<span style='font-weight:bold'>www:</span><a href='" + (hladisko.www.indexOf('http') == -1 ? 'http://' + hladisko.www : hladisko.www) + "' target='_blank'>" + hladisko.www + "</s><br>"; 253 254 255 if(isVenue == false) 256 { 257 if (lokalita != "empik") 258 content += "<br/><b>" + lang["Podujatia"] + "</b> (PoÄet predstavenÃ)<br/>"; 259 else 260 content += "<br/><b>" + lang["Podujatia"] + "</b><br/>"; 261 262 var buff_podujatia = new Array(); 263 264 for (var i in hladisko.predstavenia) { 265 if (hladisko.predstavenia.hasOwnProperty(i)) { 266 var predstavenie = hladisko.predstavenia[i]; 267 var podujatie = predstavenie.podujatie; 268 269 if (isnull(buff_podujatia[podujatie.id_podujatie_out])) 270 buff_podujatia[podujatie.id_podujatie_out] = dic_podujatie_out[podujatie.id_podujatie_out]; 271 } 272 } 273 274 for (var i in buff_podujatia) { 275 if (buff_podujatia.hasOwnProperty(i)) { 276 var podujatie = buff_podujatia[i]; 277 var c = 0; 278 279 for (var ii in podujatie.podujatia) { 280 if (podujatie.podujatia.hasOwnProperty(ii)) { 281 for (var iii in podujatie.podujatia[ii].predstavenia) { 282 if (podujatie.podujatia[ii].predstavenia.hasOwnProperty(iii)) { 283 if (podujatie.podujatia[ii].predstavenia[iii].hladisko.id == hladisko.id) 284 c++; 285 } 286 } 287 } 288 } 289 290 content += "<a href='" + absoluteUri + "Event/" + podujatie.id + (window.location.href.indexOf("iframe") != -1 ? "?iframe" : "") + "'>" + podujatie.nazov + " (" + c + ")</a><br/>
290"; 291 } 292 } 293 294 295 content += "<br/>"; 296 content += "<a class='btn btn-navigacia pull-right' style='margin-left:10px' href='javascript:SetVenueFilter(" + hladisko.id + ");'>" + lang["KupitVstupenky"] + "</a>"; 297 //content += "<a class='btn btn-navigacia pull-right' style='' href='javascript:Gmap_center_H(" + hladisko.id + ");'>PriblÞ</a>"; 298 299 if (IsMobile()) 300 content += "<a href='geo:" + hladisko.LAT + ", " + hladisko.LON + "' class='btn btn-navigacia pull-right'>" + lang["Navigacia"] + "</a><br/>"; 301 else 302 content += "<a href='http://maps.google.com/?daddr=" + hladisko.LAT + "," + hladisko.LON + "' class='btn btn-navigacia pull-right' target='_blank'>" + lang["Navigacia"] + "</a>"; 303 304 } 305 306 content += "</div>"; 307 308 infowindow = new google.maps.InfoWindow({ 309 content: content 310 }); 311 hladisko["infowindow"] = infowindow; 312 } 313 314 if (infoWindowOpened != null) 315 infoWindowOpened.close(); 316 317 infowindow.open(map, marker); 318 infoWindowOpened = infowindow; 319 }); 320} 321 322function Gmap_center_H(id_hladisko) { 323 var hladisko = dic_hladisko[id_hladisko]; 324 map.setCenter(new google.maps.LatLng(hladisko.LAT, hladisko.LON)); 325 map.setZoom(16); 326} 327 328function SetVenueFilter(id_hladisko) { 329 if ($("#search_venue").length != 0) { 330 $("#search_venue").selectpicker('val', '' + id_hladisko); 331 search_venue_change(); 332 } 333 334 $('html,body').animate({ 335 scrollTop: $("#vstupenky").offset().top 336 }); 337 338 $("#vyber-hladisko").removeClass("hidden"); 339} 340 341function createBoundsForMarkers(markers) { 342 var bounds = new google.maps.LatLngBounds(); 343 $.each(markers, function () { 344 bounds.extend(this.getPosition()); 345 }); 346 return bounds; 347} 348 349function getBoundsZoomLevel(bounds, mapDim) { 350 var WORLD_DIM = { height: 256, width: 256 }; 351 var ZOOM_MAX = 16; // Viac sa to nepriblizi, aj keby bol len jeden marker 352 353 function latRad(lat) { 354 var sin = Math.sin(lat * Math.PI / 180); 355 var radX2 = Math.log((1 + sin) / (1 - sin)) / 2; 356 return Math.max(Math.min(radX2, Math.PI), -Math.PI) / 2; 357 } 358 359 function zoom(mapPx, worldPx, fraction) { 360 return Math.floor(Math.log(mapPx / worldPx / fraction) / Math.LN2); 361 } 362 363 var ne = bounds.getNorthEast();
364 var sw = bounds.getSouthWest(); 365 366 var latFraction = (latRad(ne.lat()) - latRad(sw.lat())) / Math.PI; 367 368 var lngDiff = ne.lng() - sw.lng(); 369 var lngFraction = ((lngDiff < 0) ? (lngDiff + 360) : lngDiff) / 360; 370 371 var latZoom = zoom(mapDim.height, WORLD_DIM.height, latFraction); 372 var lngZoom = zoom(mapDim.width, WORLD_DIM.width, lngFraction); 373 374 return Math.min(latZoom, lngZoom, ZOOM_MAX); 375} 376 377// Vstupom je pole obsahujuce znacky na mape 378// Funkcia vycentruje mapu tak, aby bolo vidiet vsetky puntiky 379function centruj(markers) { 380 381 // Zistime velkost mapy 382 var $mapDiv = $('#map-canvas'); 383 384 var mapDim = { 385 height: $mapDiv.height(), 386 width: $mapDiv.width() 387 } 388 389 var bounds = createBoundsForMarkers(markers); 390 map.setCenter(bounds.getCenter()); 391 map.setZoom(getBoundsZoomLevel(bounds, mapDim)); 392}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.