var tmpStore = false; var mapa = false; var objGeoCurr = false; var mainMapId = false; var tabOverlays = new Array(); var tabLabels = new Array(); function changeMainMap() { var mainMapsList = document.getElementById('selMainMap'); if (mainMapsList.selectedIndex != -1) { for (var i = mainMapsList.length - 1; i>=0; i--) { if (mainMapsList.options[i].selected) { if (mainMapsList.options[i].value != '') { mainMapId = mainMapsList.options[i].value; } } } } if (mapa) { //usuń stare obszary if (tabOverlays.length > 0) { for (var i=0; i < tabOverlays.length; i++) { if (tabOverlays[i] != null) tabOverlays[i].setMap(null); //usun obiekt tabOverlays[i] = null; } //wyzeruj tablicę obszarów tabOverlays.length = 0; } //usun stare etykietki if (tabLabels.length > 0) { for (var i=0; i < tabLabels.length; i++) { if (tabLabels[i] != null) tabLabels[i].setMap(null); //usun obiekt tabLabels[i] = null; } //wyzeruj tablicę etykietek tabOverlays.length = 0; } //usun stare komunikaty document.getElementById('details').innerHTML = ''; showAreas(mainMapId); } else document.getElementById('info').innerHTML = "[map_not_init_msg - no translation yet]"; } function switchDetails(btnId,action) { //pokazuje szczegółowy opis wybranej mapy //pokaż opis mapy if (action == 1) { var idMapy = btnId.substr(5); if (idMapy) { tmpStore = document.getElementById('searchResults').innerHTML; document.getElementById('details').style.display = 'block'; document.getElementById('searchResults').style.display = 'none'; ciag = "action=getMapDetails&mapId=" + idMapy; http.abort(); http.open("POST", "./engine/common.php", true); http.onreadystatechange=function() { if(http.readyState < 4) { document.getElementById('details').innerHTML = "trwa pobierania opisu..."; } if(http.readyState == 4) { document.getElementById('details').innerHTML = http.responseText; } } // modyfikujemy nagłówek http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //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'; } } 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 loadMap() { 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; } function getMainMaps() { var ciag = "action=getMainMaps"; http.abort(); http.open("POST", "./engine/common.php", true); http.onreadystatechange=function() { if (http.readyState == 4) eval(http.responseText); } // modyfikujemy nagłówek http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //http.setRequestHeader("Content-length", ciag.length); http.send(ciag); } function drawArea(tabPoints, label, labelPoint) { var objGeo = new google.maps.Polygon({ paths: tabPoints, strokeWeight: 1, strokeOpacity: 0.5, strokeColor: '#FF0000', fillOpacity: 0.1, fillColor: '#FF0000' }); google.maps.event.addListener(objGeo,"click", function(event) { var labelAnchor = event.latLng; if (labelAnchor) { //zmień kolor dotychczasowego wyróżnionego obszaru if (objGeoCurr != false) { objGeoCurr.setOptions({ fillOpacity: 0.1 }); } //zmień kolor klikniętego obszaru objGeo.setOptions({ fillOpacity: 0.6 }); //ustaw bieżący obszar objGeoCurr = objGeo; var ciag = "parentId=" + mainMapId + "&point_x=" +labelAnchor.lng().toFixed(5) + "&point_y=" + labelAnchor.lat().toFixed(5) + "&action=getChildDesc"; http.abort(); 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; } } // modyfikujemy nagłówek http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //http.setRequestHeader("Content-length", ciag.length); http.send(ciag); } }); google.maps.event.addListener(objGeo,"mouseover", function(event) { if (objGeo.fillOpacity != 0.6) { objGeo.setOptions({ fillOpacity: 0.5 }); } }); google.maps.event.addListener(objGeo,"mouseout", function(event) { if (objGeo.fillOpacity != 0.6) { objGeo.setOptions({ fillOpacity: 0.1 }); } }); objGeo.setMap(mapa); //dodaj do globalnej tablicy tabOverlays.push(objGeo); if (label > 1) { var objLabel = new ELabel({ 'latlng': labelPoint, 'label': label, 'classname': 'elabel' //'offset': new google.maps.Size(2, -14), }); objLabel.setMap(mapa); //dodaj do globalnej tablicy tabLabels.push(objLabel); } } //do wygaszenia function drawArrow(point,angle, label) { //var objGeo = new BDCCArrow(point,angle,'#FF0000', 0.6, label); //mapa.addOverlay(objGeo); //objGeo.setMap(mapa); } function showAreas(parentId) { //pobiera dane dla map podrzednych (sekcyjnych) i wyrysowuje po kolei ich //obszary na jednej mapie if (parentId > 0) { var currentDate = new Date(); var startTime = currentDate.getTime(); $.blockUI({ message: '' }); var ciag = "parentId=" + parentId + "&action=getChildrenCoord"; http.abort(); http.open("POST", "./engine/common.php", true); http.onreadystatechange=function() { if(http.readyState == 4) { var strRet = http.responseText; if (strRet != '0') { var tabGeo = strRet.split("|"); var objGeo = false; var bounds = new google.maps.LatLngBounds(new google.maps.LatLng(52,18)); for (var i = 0; i < tabGeo.length; i++) { var tabCoord = tabGeo[i].split(","); if (tabCoord.length > 0) { var label = false; var text = false; var tabPoints = new Array(); switch(tabCoord.length) { case 4: //widok label = tabCoord[3]; //nieuzywana - do wygaszenia drawArrow(new google.maps.LatLng(tabCoord[1],tabCoord[0]),tabCoord[2],label); break; case 5: //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])); label = tabCoord[4]; drawArea(tabPoints,label,tabPoints[0]); break; case 9: //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])); label = tabCoord[8]; drawArea(tabPoints,label,tabPoints[3]); break; } for (var inc=0; inc < tabPoints.length; inc++) { bounds.extend(tabPoints[inc]); } } } try { mapa.fitBounds(bounds); //mapa.setCenter(new google.maps.LatLng(52,18)); } catch(err) { //brak akcji } $.unblockUI(); } else { document.getElementById('details').innerHTML = 'Wybrana mapa nie posiada wpisanych arkuszy'; $.unblockUI(); } } } // modyfikujemy nagłówek http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //http.setRequestHeader("Content-length", ciag.length); http.send(ciag); } }