﻿var map; var infowindow = new google.maps.InfoWindow(); function initMainPageCalls() { $(".subcat").click(function(a) { a.preventDefault(); $(this).addClass("bold"); JqueryAjax($(this).html()) }); $("h2.drawer-handle").click(function() { $(this).next().toggle("slow") }); $.ajax({ type: "POST", url: "default.aspx/LoadDefaultPlaces", data: "{'language':'" + getLang() + "'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(a) { PlotPlaces(a.d, a.d.length) } }) } function JqueryAjax(a) { $.ajax({ type: "POST", url: "default.aspx/AttractionsWithCategory", data: "{'categoria':'" + a + "','language':'" + getLang() + "'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(b) { PlotPlaces(b.d, b.d.length) } }) } function PlotPlaces(b, h) { var l = { zoom: 9, center: new google.maps.LatLng(18.232833, -66.244349), mapTypeId: google.maps.MapTypeId.TERRAIN }; map = new google.maps.Map(document.getElementById("map_canvas"), l); var e = Math.floor(Math.random() * h); var a; var i; var k; var g; var j = 0; var c = 0; for (var d in b) { var f = e == d; createMarker(b[d], f); if (d == 0) { a = b[d].Latitud; i = b[d].Latitud; k = b[d].Longitud; g = b[d].Longitud } i = Math.min(b[d].Latitud, i); a = Math.max(b[d].Latitud, a); g = Math.min(b[d].Longitud, g); k = Math.max(b[d].Longitud, k); c = Math.sqrt(Math.pow((a - i), 2) + Math.pow((k - g), 2)); c = Math.round(c * 100); if (c >= 0 && c < 1) { j = 9 } else { if (c >= 1 && c < 2) { j = 16 } else { if (c >= 2 && c < 3) { j = 15 } else { if (c >= 3 && c < 4) { j = 15 } else { if (c >= 4 && c < 5) { j = 13 } else { if (c >= 5 && c < 6) { j = 12 } else { if (c >= 6 && c < 90) { j = 8 } else { if (c >= 90 && c < 110) { j = 9 } else { zoom = 9 } } } } } } } } } map.setCenter(new google.maps.LatLng((a + i) / 2, (k + g) / 2)); map.setZoom(j) } function createMarker(c, f) { var g; if (getLang() == "english") { g = "place" } else { g = "lugar" } var h; if (getLang() == "english") { h = "For more information press " } else { h = "Para saber m&aacute;s presione " } var j; if (getLang() == "english") { j = "here" } else { j = "aqu&iacute;" } var b = new google.maps.MarkerImage(c.Icon, new google.maps.Size(32, 32), new google.maps.Point(0, 0), new google.maps.Point(0, 32)); var i = new google.maps.MarkerImage("http://maps.gstatic.com/intl/en_ALL/mapfiles/shadow50.png", new google.maps.Size(37, 32), new google.maps.Point(0, 0), new google.maps.Point(0, 32)); var e = { coord: [0, 0, 31, 0, 31, 31, 0, 31], type: "poly" }; var d = new google.maps.Marker({ position: new google.maps.LatLng(c.Latitud, c.Longitud), map: map, shadow: i, icon: b, shape: e }); var a = '<table class="bubble"><tr><td class="bubleDiv"><h3 class="bubbleTitle"><a href='; a += g; a += "/"; a += c.Nombre.replaceAll(" ", "-").toLowerCase(); a += '.aspx class="bubbleLink">'; a += c.Nombre; a += "</a></h3>"; a += c.Descripcion.substring(0, c.Descripcion.lastIndexOf(" ")); a += ' ... <div style="margin-top:8px">'; a += h; a += "<a href="; a += g; a += "/"; a += c.Nombre.replaceAll(" ", "-").toLowerCase(); a += '.aspx class="bubbleLink">'; a += j; a += '</a></div></td><td><img src="http://s3.amazonaws.com/photos.zeepuertorico.com/'; a += c.Foto; a += '"/></td></tr></table>'; google.maps.event.addListener(d, "click", function() { infowindow.close(); infowindow.setContent(a); infowindow.open(map, d) }); if (f) { infowindow.close(); infowindow.setContent(a); infowindow.open(map, d) } return d } String.prototype.replaceAll = function(c, d) { var a = this; var b = a.indexOf(c); while (b != -1) { a = a.replace(c, d); b = a.indexOf(c) } return (a) };
