# HG changeset patch # User casties # Date 1290442583 -3600 # Node ID 49fb47bbe2e6f1b5007cb70da4920e4be24635d9 # Parent b6aa7b77d11096d029e915882d2d0c89c78557ca saving and loading maps diff -r b6aa7b77d110 -r 49fb47bbe2e6 gis_gui/blocks/layer.js --- a/gis_gui/blocks/layer.js Fri Nov 12 12:08:24 2010 +0100 +++ b/gis_gui/blocks/layer.js Mon Nov 22 17:16:23 2010 +0100 @@ -1,7 +1,7 @@ guiBlocks.prototype.addLayerBlock = function(url, baseId, params) { if (typeof(params) == "string") { - // then its table name + // then its the table name params = {"type": "layer", "table": params}; } var block = this.addBlock(url, baseId, params, function() { @@ -82,7 +82,7 @@ // create map button $(be).find(".map_create_button").click(function() { console.debug("layer create map. this=",this," block=",block); - var mapblock = blocks.addMapBlock("blocks/map.html?layer="+escape(params.name),"map",params); + var mapblock = blocks.addMapBlock("blocks/map.html?layer="+escape(params.name),"map",null,params); }); }); @@ -90,10 +90,10 @@ guiBlocks.Block.prototype.readLayerParams = function(elem,params) { // read layer parameters from html element and store in param - if (typeof(elem) == 'undefined') { + if (elem == null) { elem = this.element; } - if (typeof(param) == 'undefined') { + if (param == null) { params = this.params; } params.name = $(elem).find(".layer_name").val(); @@ -126,7 +126,7 @@ // what to do? return; } - if (typeof(google) != "undefined") { + if (google != null) { var latlng = new google.maps.LatLng(29, 116); var mapOpts = { zoom: 5, diff -r b6aa7b77d110 -r 49fb47bbe2e6 gis_gui/blocks/map.html.pt --- a/gis_gui/blocks/map.html.pt Fri Nov 12 12:08:24 2010 +0100 +++ b/gis_gui/blocks/map.html.pt Mon Nov 22 17:16:23 2010 +0100 @@ -54,12 +54,13 @@ diff -r b6aa7b77d110 -r 49fb47bbe2e6 gis_gui/blocks/map.js --- a/gis_gui/blocks/map.js Fri Nov 12 12:08:24 2010 +0100 +++ b/gis_gui/blocks/map.js Mon Nov 22 17:16:23 2010 +0100 @@ -4,15 +4,17 @@ // function after add block finished console.debug("in mapblock after block load!"); var be = block.element; + params = block.params; block.type = "map"; params.type = "map"; - params.map_layers = []; - if (typeof(firstLayer) != null) { + if (params.map_layers == null) { + params.map_layers = []; + } + if (firstLayer != null) { block.appendMapLayer(firstLayer); } - + // show block block.showMapParams(); - // show block $(be).fadeIn(); // save map params in block.param -- too early @@ -56,12 +58,13 @@ guiBlocks.Block.prototype.showMapParams = function(elem,params) { // create html with layer parameters from params - if (typeof(elem) == 'undefined') { + if (elem == null) { elem = this.element; } - if (typeof(params) == 'undefined') { + if (params == null) { params = this.params; } + $(elem).find(".map_name").val(params.name); var layers = params.map_layers; // remove old info $(elem).find(".map_layer_table .layer_info").remove(); @@ -74,10 +77,10 @@ guiBlocks.Block.prototype.readMapParams = function(elem,params) { // read layer parameters from html element and store in param - if (typeof(elem) == 'undefined') { + if (elem == null) { elem = this.element; } - if (typeof(params) == 'undefined') { + if (params == null) { params = this.params; } params.name = $(elem).find(".map_name").val(); @@ -91,16 +94,16 @@ }; guiBlocks.Block.prototype.updateMap = function(elem,map_params) { - if (! elem != null) { + if (elem == null) { elem = this.element; } - if (! map_params != null) { + if (map_params == null) { map_params = this.params; } // update and draw the google map var le = $(elem).find(".map_box").get(0); // create empty map - if (typeof(google) != "undefined") { + if (google != null) { var latlng = new google.maps.LatLng(29, 116); var mapOpts = { zoom: 5, @@ -135,7 +138,7 @@ return; } // render layer - if (typeof(google) != "undefined") { + if (google != null) { var newMarker=new google.maps.KmlLayer(kmlURL); console.debug("new marker layer=",newMarker," map=",map); newMarker.setMap(map); diff -r b6aa7b77d110 -r 49fb47bbe2e6 gis_gui/lib/blocks.js --- a/gis_gui/lib/blocks.js Fri Nov 12 12:08:24 2010 +0100 +++ b/gis_gui/lib/blocks.js Mon Nov 22 17:16:23 2010 +0100 @@ -11,7 +11,7 @@ function defined(x) { // returns if x is defined - return (typeof arguments[0] != "undefined"); + return (typeof arguments[0] !== "undefined"); } /* @@ -38,13 +38,9 @@ // create a new block and add it to the current workspaces stack guiBlocks.prototype.addBlock = function(url, baseId, params, whenDone) { - // old version compatibility - if (typeof(params) == "function") { - whenDone = params; - } // add title to url var newblock = $("
Block loading...
"); - var newid=baseId+"_"+randomString(); + var newid = baseId+"_"+randomString(); var container = this.containerElement; console.debug("addblock newid="+newid); newblock.hide(); @@ -67,12 +63,9 @@ // create new Block object var block = new guiBlocks.Block(newid, newblock); // add parameters - if (typeof(params) != "object") { + if (params == null) { // create new params params = {"id": newid}; - } else if (typeof(params.id) == "undefined") { - // must be new block (with params) - params.id = newid; } block.params = params; // add to list of blocks