//REGION GEOCERCAS var polygonsGeocercas = []; var markersGeo = []; var IsGeoVisibles = false; function initGeocercas() { //NuevaConsultaGeoCercas(); var upGeoDiv = document.createElement('div'); var upGeo = new ControlGeocercas(upGeoDiv, map); map.controls[google.maps.ControlPosition.TOP_LEFT].push(upGeoDiv); } function NuevaConsultaGeoCercas() { HideGeocercas(); DeleteGeocercas(); $("#LnkMostarGeocercas").css("display", "block"); } function VerGeocercas() { if (IsGeoVisibles) { HideGeocercas(); IsGeoVisibles = false; } else { CargaGeocercas(); IsGeoVisibles = true; } } function CargaGeocercas() { for (var i = 0; i < polygonsGeocercas.length; i++) { polygonsGeocercas[i].setMap(map); } for (var j = 0; j < markersGeo.length; j++) { markersGeo[j].setMap(map); } } function DeleteGeocercas() { for (var i = 0; i < polygonsGeocercas.length; i++) { polygonsGeocercas[i].setMap(null); } for (var j = 0; j < markersGeo.length; j++) { markersGeo[j].setMap(null); } polygonsGeocercas = []; markersGeo = []; } function HideGeocercas() { for (var i = 0; i < polygonsGeocercas.length; i++) { polygonsGeocercas[i].setMap(null); } for (var j = 0; j < markersGeo.length; j++) { markersGeo[j].setMap(null); } } function creaPoligonoGeocerca(coords, color, Geocerca) { var polygon = new google.maps.Polygon({ paths: coords, strokeColor: color, strokeOpacity: 0.8, strokeWeight: 2, fillColor: color, fillOpacity: 0.35 }); polygonsGeocercas.push(polygon); CreaMarcadorPoligonoGeocerca(coords, Geocerca); } function CreaMarcadorPoligonoGeocerca(coords, GeoCerca) { var bounds = new google.maps.LatLngBounds(); for (i = 0; i < coords.length; i++) { bounds.extend(coords[i]); } var marker = new google.maps.Marker({ position: bounds.getCenter(), title: GeoCerca }); var infowindow = new google.maps.InfoWindow({ content: '

' + GeoCerca + '

' }); marker.addListener('click', function () { closeLastOpenedInfoWindow(); infowindow.open(map, marker); lastOpenedInfoWindow = infowindow; }); markersGeo.push(marker); } function ControlGeocercas(controlDiv, map) { // Set CSS for the control border. var controlUI = document.createElement('div'); controlUI.style.marginLeft = '10px'; controlUI.style.zIndex = '0'; controlUI.style.cursor = 'pointer'; // controlUI.style.position = 'absolute'; controlUI.style.left = "0px"; controlUI.style.width = "150px"; controlUI.style.marginTop = "10px" controlUI.style.top = "0px"; controlUI.className = 'gmnoprint'; controlDiv.appendChild(controlUI); var ControlSub1 = document.createElement('div') ControlSub1.style.float = 'left'; ControlSub1.className = 'gm-style-mtc' controlUI.appendChild(ControlSub1) var ControlSub2 = document.createElement('div') ControlSub2.style.direction = 'ltr'; ControlSub2.style.overflow = 'hidden'; ControlSub2.id = "LnkMostarGeocercas" ControlSub2.style.textAlign = 'center'; ControlSub2.style.position = 'relative'; ControlSub2.style.color = 'rgb(0,0,0)'; ControlSub2.style.fontFamily = ' "Open Sans", sans-serif; '; ControlSub2.style.msUserSelect = 'none;'; ControlSub2.style.fontSize = '11px' ControlSub2.style.display = 'none' ControlSub2.style.backgroundColor = 'rgb(255,255,255)' ControlSub2.style.padding = '11px' ControlSub2.style.backgroundClip = 'padding-box' ControlSub2.style.minWidth = '28px' ControlSub2.style.fontWeight = '500' ControlSub2.style.boxShadow = '0 1px 4px -1px rgba(0,0,0,.3)'; ControlSub2.innerHTML = 'Mostrar Geocercas' ControlSub1.appendChild(ControlSub2) ControlSub1.addEventListener('click', function () { VerGeocercas(); }); } //END REGION