var ramona = { init: function() { initMapScript(); set_active_tool_button('zoom_in'); } } jQuery(document).ready(function() { ramona.init(); }); function open_map_data_producers(coords) { start_data_producers_overlay(coords); return false; } function open_cad_county_contacts(coords) { start_cad_county_overlay(coords); return false; } function open_cad_state_window(coords) { start_cad_state_overlay(coords); return false; } function open_map_query(coords) { start_info_overlay(coords); return false; } function open_map_viewer(map_image, map_type) { start_map_viewer_overlay(map_image, map_type); return false; } function start_info_overlay(coords) { //add the elements to the dom $("body").append('
'); //animate the semitransparant layer $(".lb_overlay").animate({"opacity":"0.6"}, 400, "linear"); //add the lightbox image to the DOM $("#lb_container").load("/ajax/get_map_query.php", {input_coords: coords}, function() { $("#lb_container").css({"background": "#FFFFFF"}) }); //$("#lb_container").html(coords); $("#lb_container").animate({"opacity":"1"}, 400, "linear"); // you need to initiate the removeoverlay function here, otherwise it will not execute. window.removeOverlay(); } function start_cad_state_overlay(coords) { //add the elements to the dom $("body").append('
'); //animate the semitransparant layer $(".lb_overlay").animate({"opacity":"0.6"}, 400, "linear"); //add the lightbox image to the DOM $("#lb_container").load("/ajax/get_cad_state_results.php", {input_coords: coords}, function() { $("#lb_container").css({"background": "#FFFFFF"}) }); //$("#lb_container").html(coords); $("#lb_container").animate({"opacity":"1"}, 400, "linear"); // you need to initiate the removeoverlay function here, otherwise it will not execute. window.removeOverlay(); } function start_cad_county_overlay(coords) { //add the elements to the dom $("body").append('
'); //animate the semitransparant layer $(".lb_overlay").animate({"opacity":"0.6"}, 400, "linear"); //add the lightbox image to the DOM $("#lb_container").load("/ajax/get_cad_county_results.php", {input_coords: coords}, function() { $("#lb_container").css({"background": "#FFFFFF"}) }); //$("#lb_container").html(coords); $("#lb_container").animate({"opacity":"1"}, 400, "linear"); // you need to initiate the removeoverlay function here, otherwise it will not execute. window.removeOverlay(); } function start_data_producers_overlay(coords) { //add the elements to the dom $("body").append('
'); //animate the semitransparant layer $(".lb_overlay").animate({"opacity":"0.6"}, 400, "linear"); //add the lightbox image to the DOM $("#lb_container").load("/ajax/get_data_producers_results.php", {input_coords: coords}, function() { $("#lb_container").css({"background": "#FFFFFF"}) }); //$("#lb_container").html(coords); $("#lb_container").animate({"opacity":"1"}, 400, "linear"); // you need to initiate the removeoverlay function here, otherwise it will not execute. window.removeOverlay(); } function start_map_viewer_overlay(map_image, map_type) { //add the elements to the dom $("body").append('
'); //animate the semitransparant layer $(".lb_overlay").animate({"opacity":"0.6"}, 400, "linear"); //add the lightbox image to the DOM if (map_type == 1) { $("#map_overlay_container").load("/map_viewer.html", {map_image: map_image, data_producers: 1}, function() { $("#lb_container").css({"background": "#FFFFFF"}) }); } else if (map_type == 2) { $("#map_overlay_container").load("/map_viewer.html", {map_image: map_image}, function() { $("#lb_container").css({"background": "#FFFFFF"}) }); } else if (map_type == 3) { $("#map_overlay_container").load("/cad_map_viewer.html", {map_image: map_image, map_type: 1}, function() { $("#lb_container").css({"background": "#FFFFFF"}) }); } else if (map_type == 4) { $("#map_overlay_container").load("/cad_map_viewer.html", {map_image: map_image, map_type: 2}, function() { $("#lb_container").css({"background": "#FFFFFF"}) }); } else if (map_type == 5) { $("#map_overlay_container").load("/cad_map_viewer.html", {map_image: map_image, map_type: 3}, function() { $("#lb_container").css({"background": "#FFFFFF"}) }); } else if (map_type == 6) { $("#map_overlay_container").load("/cad_map_viewer.html", {map_image: map_image, map_type: 4}, function() { $("#lb_container").css({"background": "#FFFFFF"}) }); } $("#map_overlay_container").animate({"opacity":"1"}, 400, "linear"); // you need to initiate the removeoverlay function here, otherwise it will not execute. window.remove_map_verlay(); } function removeOverlay() { // allow users to be able to close the lightbox $(".lb_overlay").click(function(){ $("#lb_container, .lb_overlay").animate({"opacity":"0"}, 200, "linear", function(){ $("#lb_container, .lb_overlay").remove(); }); }); } function remove_map_verlay() { // allow users to be able to close the lightbox $(".lb_overlay").click(function(){ $("#map_overlay_container, .lb_overlay").animate({"opacity":"0"}, 200, "linear", function(){ $("#map_overlay_container, .lb_overlay").remove(); }); }); } function remove_overlay_button() { // allow users to be able to close the lightbox $("#lb_container, .lb_overlay").animate({"opacity":"0"}, 200, "linear", function(){ $("#lb_container, .lb_overlay").remove(); }); } function remove_map_overlay_button() { // allow users to be able to close the lightbox $("#map_overlay_container, .lb_overlay").animate({"opacity":"0"}, 200, "linear", function(){ $("#map_overlay_container, .lb_overlay").remove(); }); } var mapContainerDiv; var map_div; var map_image; var map_form; var rubber_band_div; var minx; var miny; var maxx; var maxy; var startx; var starty; var xswitch=0; var yswitch=0; function submit_info_request(x, y, map_type) { if (document.layers) { document.releaseEvents(Event.MOUSEMOVE); } var r = rubber_band_div; rbX1 = parseInt(r.style.left) - findPosX(map_image); rbY1 = parseInt(r.style.top) - findPosY(map_image); rbX2 = rbX1 + parseInt(r.style.width); rbY2 = rbY1 + parseInt(r.style.height); //var input=map_form.clickCoords; document.map_form.input_coords.value = rbX1+','+rbY1+';'+rbX2+','+rbY2; //input.setAttribute('value', rbX1 + " " + rbY1 + " " + rbX2 + " " + rbY2); if (map_type == 'data_layer') { open_map_query(document.map_form.input_coords.value); } if (map_type == 'data_producer') { open_map_data_producers(document.map_form.input_coords.value); } if (map_type == 'cad_state_contacts') { open_cad_state_window(document.map_form.input_coords.value); } if (map_type == 'cad_county_contacts') { open_cad_county_contacts(document.map_form.input_coords.value); } } function mouseDown(evt) { // If it's not the left mouse button ignore if ((browser.ns && evt.which != 1) || (browser.ie && event.button != 1)) { return true; } var x = (browser.ns) ? evt.pageX : event.clientX; var y = (browser.ns) ? evt.pageY : event.clientY; // If it's IE we need to add the scroll offset to the x and y if (browser.ie) { x = x + find_page_offsetx(); y = y + find_page_offsety(); } switch(map_click_option) { case "zoom_in": start_rubber(x, y); case "zoom_out": start_rubber(x, y); case "recenter": start_pan(x, y); case "info": start_rubber(x, y); case "dp_info": start_rubber(x, y); case "nc_info": start_rubber(x, y); case "cad_state_info": start_rubber(x, y); default: } if (document.layers) { document.captureEvents(Event.MOUSEMOVE); } if (map_click_option != "recenter") { document.onmousemove = mouse_move; } document.onmouseup = mouseUp; return false; } function mouse_move(evt) { //alert("mouse_move"); var x = (browser.ns) ? evt.pageX : event.clientX; var y = (browser.ns) ? evt.pageY : event.clientY; // If it's IE we need to add the scroll offset to the x and y if (browser.ie) { x = x + find_page_offsetx(); y = y + find_page_offsety(); } if (!isOnMap(x,y)) return false; switch(map_click_option) { case "zoom_in": move_rubber(x, y); return false; case "zoom_out": move_rubber(x, y); return false; case "recenter": submit_pan(x, y); return false; case "info": move_rubber(x, y); return false; case "dp_info": move_rubber(x, y); return false; case "nc_info": move_rubber(x, y); return false; case "cad_state_info": move_rubber(x, y); return false; default: } } function mouseUp(evt) { //alert("mouseUp"); var x = (browser.ns) ? evt.pageX : event.clientX; var y = (browser.ns) ? evt.pageY : event.clientX; // If it's IE we need to add the scroll offset to the x and y if (browser.ie) { x = x + find_page_offsetx(); y = y + find_page_offsety(); } switch(map_click_option) { case "zoom_in": stop_rubber(x, y); document.map_form.submit(); break; case "zoom_out": stop_rubber(x, y); document.map_form.submit(); break; case "recenter": submit_pan(x, y); document.map_form.submit(); break; case "info": submit_info_request(x, y, 'data_layer'); break; case "dp_info": submit_info_request(x, y, 'data_producer'); break; case "nc_info": submit_info_request(x, y, 'cad_county_contacts'); break; case "cad_state_info": submit_info_request(x, y, 'cad_state_contacts'); break; default: } document.onmousemove = null; document.onmouseup = null; } function start_rubber(x, y) { //alert("start_rubber(" + x + "," + y + ")"); minx = x; miny = y; maxx = x; maxy = y; startx = x; starty = y; if (document.all) { // IE var r = rubber_band_div; r.style.width = 0; r.style.height = 0; r.style.pixelLeft = x; r.style.pixelTop = y; r.style.visibility = 'visible'; } else if (document.getElementById) { var r = rubber_band_div; r.style.width = 0; r.style.height = 0; r.style.left = x + 'px'; r.style.top = y + 'px'; r.style.visibility = 'visible'; } } function start_pan(x,y) { //alert("start_pan(" + x + "," + y + ")"); mapObject = new MapObject(); mapObject.mousedownX = x; mapObject.mousedownY = y; } function submit_pan() { if (document.layers) { document.releaseEvents(Event.MOUSEMOVE); } var r = rubber_band_div; rbX1 = parseInt(r.style.left) - findPosX(map_image); rbY1 = parseInt(r.style.top) - findPosY(map_image); rbX2 = rbX1 + parseInt(r.style.width); rbY2 = rbY1 + parseInt(r.style.height); document.map_form.input_coords.value = rbX1+','+rbY1+';'+rbX2+','+rbY2; document.map_form.submit(); } function move_rubber(x, y) { var r = rubber_band_div; if (document.all) { //r.style.width = x - r.style.pixelLeft; //r.style.height = y - r.style.pixelTop; if (x < startx) { if (xswitch==0) { xswitch=1 maxx = minx; } minx = x; r.style.pixelLeft = x; } else { if (xswitch==1) { xswitch=0; } maxx = x; } if (y mapRight) return false; if (y < mapTop) return false; if (y > mapBottom) return false; return true; } function set_map_click_opt(opt) { map_click_option = opt; switch (opt) { case "zoom_in": set_cursor(map_div, "crosshair"); break; case "zoom_out": set_cursor(map_div, "crosshair"); break; case "recenter": set_cursor(map_div, "move"); break; case "info": set_cursor(map_div, "default"); break; case "dp_info": set_cursor(map_div, "default"); break; case "nc_info": set_cursor(map_div, "default"); break; case "cad_state_info": set_cursor(map_div, "default"); break; default: set_cursor(map_div, "crosshair"); } //setActiveToolBtn(map_click_option); } function set_cursor(elem, style) { if (elem) { elem.style.cursor = style; } //alert(elem + ", " + style); } function setActiveToolBtn_dep(tool) { var tools = new Array(4); tools[0] = 'zoom_in'; tools[1] = 'zoom_out'; tools[2] = 'pan'; tools[3] = 'info'; var x = 0; for (x=0; x < tools.length; x++) { //alert(tools[x]); if (tools[x] == tool) { //MM_swapImage(tools[x], '', tools[x] + 'On.gif', 1); } else { //MM_swapImage(tools[x], '', tools[x] + '.gif', 1); } // reset the mouseover image restore array document.MM_sr=new Array; } } function findPosX(obj) { var curleft = 0; if (obj.offsetParent) { while (obj.offsetParent) { curleft += obj.offsetLeft obj = obj.offsetParent; } } else if (obj.x) { curleft += obj.x; } return curleft; } function findPosY(obj) { var curtop = 0; if (obj.offsetParent) { while (obj.offsetParent) { curtop += obj.offsetTop obj = obj.offsetParent; } } else if (obj.y) { curtop += obj.y; } return curtop; } function find_page_offsetx() { if (document.all||document.getElementById) { return document.body.scrollLeft; } else if (document.layers) { return pageXOffset; } } function find_page_offsety() { if (document.all||document.getElementById) { return document.body.scrollTop; } else if (document.layers) { return pageYOffset; } } // BrowserCheck Object function BrowserCheck() { var b = navigator.appName if ((navigator.userAgent.indexOf("Opera 6")!=-1) || (navigator.userAgent.indexOf("Opera/6")!=-1)) { this.b='op'; } if (b == "Netscape") { this.b = "ns"; } else if (b=="Microsoft Internet Explorer") { this.b = "ie"; } else { this.b = b; } this.version = navigator.appVersion; //alert("Navigateur "+navigator.userAgent ); this.v = parseInt(this.version); this.ns = (this.b=="ns" && this.v>=4); this.ns4 = (this.b=="ns" && this.v==4); this.ns5 = (this.b=="ns" && this.v==5); // NS6 this.ie = (this.b=="ie" && this.v>=4); this.ie4 = (this.version.indexOf('MSIE 4')>0); this.ie5 = (this.version.indexOf('MSIE 5')>0); this.min = (this.ns||this.ie); } function MapObject() { } var browser = new BrowserCheck(); function initMapScript() { if (document.getElementById) { mapContainerDiv = document.getElementById('mapcontainer'); map_div = document.getElementById('map_div'); map_image = document.getElementById('mapimg'); map_form = document.getElementById('map_form'); rubber_band_div = document.getElementById('rubberband'); } else if (document.all) { mapContainerDiv = document.all.mapcontainer; map_div = document.all.map_div; map_image = document.all.mapimg; map_form = document.all.map_form; rubber_band_div = document.all.rubberband; } //alert('map_div=' + map_div + '\nmap_image=' + map_image + '\nmap_form=' + map_form + '\nrubber_band_div=' + rubber_band_div); // There is a bug in Firefox that makes the map image align about 50px to the right // inside the mapcontainer div when the page is loaded. We need to manually // reset it here. Even putting left: 0px in the CSS file doesn't work. map_div.style.left = 0; map_div.style.top = 0; map_div.onmousedown = mouseDown; set_map_click_opt("zoom_in"); } var current_map_function = 'zoom_in'; function set_active_tool_button(map_function) { $("#"+current_map_function+"").attr({src: "http://gisinventory.net/images/map/"+current_map_function+"_off.gif"}); document.map_form.command.value = map_function; switch (map_function) { case "zoom_in": $("#zoom_in").attr({src: "http://gisinventory.net/images/map/zoom_in_on.gif"}); set_map_click_opt("zoom_in"); break; case "zoom_out": $("#zoom_out").attr({src: "http://gisinventory.net/images/map/zoom_out_on.gif"}); set_map_click_opt("zoom_out"); break; case "info": $("#info").attr({src: "http://gisinventory.net/images/map/info_on.gif"}); set_map_click_opt("info"); break; case "dp_info": $("#info").attr({src: "http://gisinventory.net/images/map/info_on.gif"}); set_map_click_opt("dp_info"); break; case "nc_info": $("#info").attr({src: "http://gisinventory.net/images/map/info_on.gif"}); set_map_click_opt("nc_info"); break; case "cad_state_info": $("#info").attr({src: "http://gisinventory.net/images/map/info_on.gif"}); set_map_click_opt("cad_state_info"); break; case "recenter": $("#recenter").attr({src: "http://gisinventory.net/images/map/recenter_on.gif"}); set_map_click_opt("recenter"); break; } current_map_function = map_function; } function refresh_map() { document.map_form.map_input.value=0; document.map_form.command.value=''; document.map_form.submit(); } function change_map_layer(form_ele) { form_ele.checked = true; refresh_map(); }