//var http = false; var mapa =false; //przechowuje listę wynikow wyszukiwań podczas wyswietlania szczegolow rekordu var tmpStore = false; //tablica na obszary var tabOverlays = new Array(); //tablica na aktualnie wyświetlone mapy var tabCurrGeos = new Array(); function resizeDiv(container,percent_width, percent_height) { if ((percent_width > 0) && (percent_width < 100) & (percent_height > 0) && (percent_height < 100)) { with(Math) { tabDim = getWindowSize().split(';'); if (tabDim.length == 2) { //pozostawiamy oryginalna szerokosc z css-a //container.style.width = floor(tabDim[0] * percent_width / 100) + 'px'; container.style.height = floor(tabDim[1] * percent_height / 100) + 'px'; } } } } function load() { var mapOptions = { zoom: 7, center: new google.maps.LatLng(51.1139, 17.0700), draggableCursor:"crosshair", OverviewMapControl: true, keyboardShortcuts: true }; resizeDiv(document.getElementById('map'), 60, 75); var map = new google.maps.Map(document.getElementById("map"),mapOptions); if (map) mapa = map; //sprawdz czy w metodzie GET nie przekazano id-ka rekordu var url = window.location.href; var id = getValue(url,"id"); // jesli wykryto id w parametrach to sprawdz czy to nie permanentny link if (!id) id = getPermId(url); if ((id) != false) { if (isNumeric(id)) { //if ((id > 0) && (total_results == 1)) { if (id > 0) { fillList(false,false,false,1,1,"1,2",false,id); } else document.getElementById('searchResults').innerHTML = "brak wyników"; } else document.getElementById('searchResults').innerHTML = "brak wyników"; } function createMarker(point, desc) { var marker = new google.maps.Marker(point); google.maps.event.addListener(marker, "click", function() { marker.openInfoWindow(desc); }); return marker; } var infoWindow = new google.maps.InfoWindow(); google.maps.event.addListener(map,"click", function(event) { var point = event.latLng; if (point) { if (tabOverlays != undefined) { for (var i=0; i < tabOverlays.length; i++) { if (tabOverlays[i] != undefined) { for (var k=0; k < tabOverlays[i].length; k++) { tabOverlays[i][k].setMap(null); tabCurrGeos[i] = false; } } } } infoWindow.setContent("długość geogr. " + getDegrees(point.lng(),'lng') + "
" + "szerokość geogr. " + getDegrees(point.lat(),'lat')); infoWindow.setPosition(point); infoWindow.open(map); //zapisz wspolrzedne kliknietego punktu document.getElementById('point_x').value = point.lng(); document.getElementById('point_y').value = point.lat(); //ustaw na 1-szą strone wynikow filterRecord(1); } }); //załaduj hasła getTerms('selKeywords','id_hasla',''); //włącz szybki wybór w kontrolce $('.multipleSelect').fastselect({placeholder: "---wybierz---", noResultsText: "brak wyników"}); } function getDegrees(value,coord) { var sufix = ''; if (value < 0) { if (coord == 'lng') sufix = 'W'; if (coord == 'lat') sufix = 'S'; value = -value; } else { if (coord == 'lng') sufix = 'E'; if (coord == 'lat') sufix = 'N'; } with(Math) { var pDeg = floor(value) + "° "; var pMin = floor(((value) - floor(value))*60) + "' "; var pSec = floor((((value) - floor(value))*60 - floor(((value) - floor(value))*60))*60) + "'' "; } return pDeg + pMin + pSec + sufix; } function getAreaCenter(zakres_x1, zakres_x2, zakres_y1, zakres_y2) { //zakresy obszaru do pokazania var centrum = false; if ((zakres_x1 != "") && (zakres_x2 != "") && (zakres_y1 != "") && (zakres_y2 != "")) { // ustalenie środka obszaru var x = Number(zakres_x1) + (Number(zakres_x2) - Number(zakres_x1)) /2; var y = Number(zakres_y1) + (Number(zakres_y2) - Number(zakres_y1)) /2; centrum = new google.maps.LatLng(y,x); } return centrum; } function switchGeo(btnId,moveToArea) { var idMapy = btnId.substr(5); var imgSrc = document.getElementById(btnId).src; if ((imgSrc.substr(imgSrc.length - 9) == "sepia.gif")) { var tabGeo = (document.getElementById(('geo' + idMapy)).value).split('|'); if (tabGeo.length > 0) { //sprawdź czy obszary mapy nie zostaly juz utworzone wczesniej if (tabOverlays[idMapy] == undefined) { tabOverlays[idMapy] = new Array(); //odczytaj po jednym obszarze i dolacz go do tablicy obszarów for (var i =0; i < tabGeo.length; i++) { var objGeo = false; var text = false; var tabPoints = new Array(); var tabCoord = tabGeo[i].split(","); if (tabCoord.length > 0) { switch(tabCoord.length) { case 3: //widok tabPoints.push(new google.maps.LatLng(tabCoord[1],tabCoord[0])); //TODO: zmienić bibliotekę do strzałek //objGeo = new BDCCArrow(new google.maps.LatLng(tabCoord[1],tabCoord[0]), tabCoord[2],'#FF0000', 0.6, text); break; case 4: //uproszczony obszar tabPoints.push(new google.maps.LatLng(tabCoord[3],tabCoord[0])); tabPoints.push(new google.maps.LatLng(tabCoord[3],tabCoord[1])); tabPoints.push(new google.maps.LatLng(tabCoord[2],tabCoord[1])); tabPoints.push(new google.maps.LatLng(tabCoord[2],tabCoord[0])); tabPoints.push(new google.maps.LatLng(tabCoord[3],tabCoord[0])); objGeo = new google.maps.Polygon({ paths: tabPoints, strokeWeight: 1, strokeOpacity: 0.5, strokeColor: '#FF0000', fillOpacity: 0.1, fillColor: '#FF0000' }); break; case 8: //pełny obszar tabPoints.push(new google.maps.LatLng(tabCoord[4],tabCoord[0])); tabPoints.push(new google.maps.LatLng(tabCoord[5],tabCoord[1])); tabPoints.push(new google.maps.LatLng(tabCoord[6],tabCoord[2])); tabPoints.push(new google.maps.LatLng(tabCoord[7],tabCoord[3])); tabPoints.push(new google.maps.LatLng(tabCoord[4],tabCoord[0])); objGeo = new google.maps.Polygon({ paths: tabPoints, strokeWeight: 1, strokeOpacity: 0.5, strokeColor: '#FF0000', fillOpacity: 0.1, fillColor: '#FF0000' }); break; } } //włączone autoskalowanie? if (moveToArea) { if (tabPoints.length > 0) { var bounds = new google.maps.LatLngBounds(); for (var inc=0; inc < tabPoints.length; inc++) { bounds.extend(tabPoints[inc]); } mapa.fitBounds(bounds); } } //dodaj obiekt podarkusza do tablicy arkuszy danej mapy tabOverlays[idMapy][i] = objGeo; } } setGeoState(idMapy, true); document.getElementById(btnId).src="./images/mapa.gif"; document.getElementById(btnId).title = "Ukryj obszar"; } else { //brak prawidłowych zakresów wiec wyswietl domyslny obszar mapa.setCenter(new google.maps.LatLng(51.1139, 17.0700)); mapa.setZoom(9); } value = "Ukryj georef" } else { setGeoState(idMapy, false); } } function setGeoState(idMapy, state) { if (idMapy) { if (state == true) { //dodaj obiekty geo do mapy na ekranie for (var i=0; i < tabOverlays[idMapy].length; i++) { //mapa.addOverlay(tabOverlays[idMapy][i]); tabOverlays[idMapy][i].setMap(mapa); } //uaktualnij tabelę wyświetlonych aktualnie map tabCurrGeos[idMapy] = true; } else { for (var i=0; i < tabOverlays[idMapy].length; i++) { //mapa.removeOverlay(tabOverlays[idMapy][i]); tabOverlays[idMapy][i].setMap(null); //uaktualnij tabelę wyświetlonych aktualnie map tabCurrGeos[idMapy] = false; } } fixMapBtn(); } } function switchDetails(btnId,action) { //pokazuje szczegółowy opis wybranej mapy //pokaż opis mapy if (action == 1) { var idMapy = btnId.substr(5); if (idMapy) { //zapisz listę wyników wyszukiwań tmpStore = document.getElementById('searchResults').innerHTML; document.getElementById('details').style.display = 'block'; document.getElementById('searchResults').style.display = 'none'; document.getElementById('details').style.display = 'block'; ciag = "action=getMapDetails&lstButtons=1&mapId=" + idMapy; http.abort(); //resetuje dotychczasowe funcje obslugi if( navigator.appName != "Microsoft Internet Explorer") http.onreadystatechange = null; http.open("POST", "./engine/common.php", true); http.onreadystatechange=function() { if(http.readyState < 4) { document.getElementById('details').innerHTML = "trwa pobieranie opisu..."; } if(http.readyState == 4) { document.getElementById('details').innerHTML = http.responseText; fixMapBtn(); } } // modyfikujemy nagłówek http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //tego już przeglądarka nie może zmienić //http.setRequestHeader("Content-length", ciag.length); http.send(ciag); } } else { //wyswietl listę map dla danego punktu z kopii if (tmpStore != false) document.getElementById('searchResults').innerHTML = tmpStore; document.getElementById('details').style.display = 'none'; document.getElementById('searchResults').style.display = 'block'; fixMapBtn(); } } function showAllGeos() { alert("funkcja nie zaimplementowana"); } function hideAllGeos() { for (var i in tabCurrGeos) { setGeoState(i,false); } } function switchAdvancedSearch() { if (document.getElementById('btnMoreOptions').value == "Pokaż wszystkie kryteria") { document.getElementById('advancedSearch').style.display = 'block'; document.getElementById('btnMoreOptions').value = "<=Ukryj kryteria"; //pokaż ilości obiektow //getCatStats(); } else { document.getElementById('advancedSearch').style.display = 'none'; document.getElementById('btnMoreOptions').value = "Pokaż wszystkie kryteria"; } } function switchComplement(value) { if (value == 'miedzy') document.getElementById('complement').style.display = 'inline'; else document.getElementById('complement').style.display = 'none'; document.getElementById('data_wydania_stop').value = ''; filterRecord(); } function filterRecord(page) { //var filter = document.getElementById('phrase').value var filter = false; if ((page < 0) || (isNumeric(page) == false)) page = 1; var point_x = document.getElementById('point_x').value; var point_y = document.getElementById('point_y').value; var resultsPerPage = 10; // "1" - przycisk // "2" - przycisk var lstButtons = "1,2"; fillList(filter, point_x, point_y, page, resultsPerPage, lstButtons); }