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_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("http://nc.gisinventory.net/ajax/get_map_query.php", {input_coords: coords}, function() { $("#lb_container").css({"background": "#FFF"}) }); //$("#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("http://nc.gisinventory.net/ajax/get_data_producers_results.php", {input_coords: coords}, function() { $("#lb_container").css({"background": "#FFF"}) }); //$("#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("http://nc.gisinventory.net/map_viewer.html", {map_image: map_image, data_producers: 1}, function() { $("#lb_container").css({"background": "#FFF"}) }); } else if (map_type == 2) { $("#map_overlay_container").load("http://nc.gisinventory.net/map_viewer.html", {map_image: map_image}, function() { $("#lb_container").css({"background": "#FFF"}) }); } $("#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); } } 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); 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; 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; 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