annotate gis_gui/blocks/map.js @ 253:d6c7bedf4370

New reload button active in upper right corner of block
author fknauft
date Fri, 23 Sep 2011 13:11:46 +0200
parents bba7dd7b6b4c
children 52b1247140b7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1
67
b6aa7b77d110 work on saving and loading maps
casties
parents: 65
diff changeset
2 guiBlocks.prototype.addMapBlock = function(url, baseId, params, firstLayer) {
b6aa7b77d110 work on saving and loading maps
casties
parents: 65
diff changeset
3 var block = this.addBlock(url, baseId, params, function() {
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4 // function after add block finished
67
b6aa7b77d110 work on saving and loading maps
casties
parents: 65
diff changeset
5 console.debug("in mapblock after block load!");
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
6 var be = block.element;
68
49fb47bbe2e6 saving and loading maps
casties
parents: 67
diff changeset
7 params = block.params;
67
b6aa7b77d110 work on saving and loading maps
casties
parents: 65
diff changeset
8 block.type = "map";
b6aa7b77d110 work on saving and loading maps
casties
parents: 65
diff changeset
9 params.type = "map";
68
49fb47bbe2e6 saving and loading maps
casties
parents: 67
diff changeset
10 if (params.map_layers == null) {
49fb47bbe2e6 saving and loading maps
casties
parents: 67
diff changeset
11 params.map_layers = [];
49fb47bbe2e6 saving and loading maps
casties
parents: 67
diff changeset
12 }
49fb47bbe2e6 saving and loading maps
casties
parents: 67
diff changeset
13 if (firstLayer != null) {
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
14 block.appendMapLayer(firstLayer);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
15 }
68
49fb47bbe2e6 saving and loading maps
casties
parents: 67
diff changeset
16 // show block
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
17 block.showMapParams();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
18 $(be).fadeIn();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
19
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
20 // save map params in block.param -- too early
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
21 //params = block.readLayerParams();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
22
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
23 // load map
237
35c3d0ce2914 show line and polygon-layer
fknauft
parents: 236
diff changeset
24 var map=block.updateMap(be,params);
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
25
65
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
26 // add layer button
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
27 $(be).find(".layer_add_button").click(function() {
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
28 console.debug("layer add");
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
29 params = block.readMapParams();
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
30 block.addMapLayer(be,params);
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
31 });
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
32 // update button
70
9ec7e32e8ad3 working on maps
casties
parents: 69
diff changeset
33 $(be).find(".map_update_button").click(function () {
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
34 console.debug("map update");
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
35 params = block.readMapParams();
237
35c3d0ce2914 show line and polygon-layer
fknauft
parents: 236
diff changeset
36 map=block.updateMap(be,params);
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
37 });
253
d6c7bedf4370 New reload button active in upper right corner of block
fknauft
parents: 249
diff changeset
38 // reload button
d6c7bedf4370 New reload button active in upper right corner of block
fknauft
parents: 249
diff changeset
39 $(be).find(".reload_button").click(function () {
d6c7bedf4370 New reload button active in upper right corner of block
fknauft
parents: 249
diff changeset
40 console.debug("map update");
d6c7bedf4370 New reload button active in upper right corner of block
fknauft
parents: 249
diff changeset
41 params = block.readMapParams();
d6c7bedf4370 New reload button active in upper right corner of block
fknauft
parents: 249
diff changeset
42 map=block.updateMap(be,params);
d6c7bedf4370 New reload button active in upper right corner of block
fknauft
parents: 249
diff changeset
43 });
d6c7bedf4370 New reload button active in upper right corner of block
fknauft
parents: 249
diff changeset
44
226
0a1dee507612 general commit
fknauft
parents: 159
diff changeset
45 // new window button
237
35c3d0ce2914 show line and polygon-layer
fknauft
parents: 236
diff changeset
46 /* $(be).find(".map_newwindow_button").click(function () {
226
0a1dee507612 general commit
fknauft
parents: 159
diff changeset
47 console.debug("map in new window");
0a1dee507612 general commit
fknauft
parents: 159
diff changeset
48 params = block.readMapParams();
0a1dee507612 general commit
fknauft
parents: 159
diff changeset
49 var newWindow = window.open("blocks/map_newwindow.html");
237
35c3d0ce2914 show line and polygon-layer
fknauft
parents: 236
diff changeset
50 map=block.updateMap(newWindow.document.getElementById("map_box"),params);
226
0a1dee507612 general commit
fknauft
parents: 159
diff changeset
51 });
237
35c3d0ce2914 show line and polygon-layer
fknauft
parents: 236
diff changeset
52 */
35c3d0ce2914 show line and polygon-layer
fknauft
parents: 236
diff changeset
53 // reload button
35c3d0ce2914 show line and polygon-layer
fknauft
parents: 236
diff changeset
54 $(be).find(".map_reload_button").click(function () {
35c3d0ce2914 show line and polygon-layer
fknauft
parents: 236
diff changeset
55 console.debug("reload map");
253
d6c7bedf4370 New reload button active in upper right corner of block
fknauft
parents: 249
diff changeset
56 block.reloadMap();
237
35c3d0ce2914 show line and polygon-layer
fknauft
parents: 236
diff changeset
57 });
35c3d0ce2914 show line and polygon-layer
fknauft
parents: 236
diff changeset
58 // save button
70
9ec7e32e8ad3 working on maps
casties
parents: 69
diff changeset
59 $(be).find(".map_save_button").click(function () {
67
b6aa7b77d110 work on saving and loading maps
casties
parents: 65
diff changeset
60 console.debug("map save. this=",this," block=",block);
b6aa7b77d110 work on saving and loading maps
casties
parents: 65
diff changeset
61 params = block.readMapParams(be,params);
b6aa7b77d110 work on saving and loading maps
casties
parents: 65
diff changeset
62 block.storeBlock("test1");
b6aa7b77d110 work on saving and loading maps
casties
parents: 65
diff changeset
63 });
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
64 });
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
65 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
66
70
9ec7e32e8ad3 working on maps
casties
parents: 69
diff changeset
67 guiBlocks.Block.prototype.appendMapLayer = function (layerparams) {
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
68 // add layer to this map
70
9ec7e32e8ad3 working on maps
casties
parents: 69
diff changeset
69 var layerinfo = {
9ec7e32e8ad3 working on maps
casties
parents: 69
diff changeset
70 display: true,
9ec7e32e8ad3 working on maps
casties
parents: 69
diff changeset
71 layer: layerparams
9ec7e32e8ad3 working on maps
casties
parents: 69
diff changeset
72 };
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
73 var layers = this.params.map_layers;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
74 layers.push(layerinfo);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
75 // update indexes
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
76 for (var i = 0; i < layers.length; i++) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
77 layers[i].idx = i;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
78 }
65
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
79 return this.params;
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
80 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
81
72
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
82 guiBlocks.Block.prototype.deleteMapLayer = function (idx) {
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
83 // remove layer from this map
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
84 var layers = this.params.map_layers;
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
85 layers.splice(idx,1);
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
86 // update indexes
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
87 for (var i = 0; i < layers.length; i++) {
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
88 layers[i].idx = i;
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
89 }
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
90 return this.params;
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
91 };
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
92
70
9ec7e32e8ad3 working on maps
casties
parents: 69
diff changeset
93 guiBlocks.Block.prototype.showMapParams = function (elem, params) {
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
94 // create html with layer parameters from params
72
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
95 var i, layers, $tmpl, lp, idx;
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
96 var block = this;
68
49fb47bbe2e6 saving and loading maps
casties
parents: 67
diff changeset
97 if (elem == null) {
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
98 elem = this.element;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
99 }
68
49fb47bbe2e6 saving and loading maps
casties
parents: 67
diff changeset
100 if (params == null) {
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
101 params = this.params;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
102 }
72
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
103 var $elem = $(elem);
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
104 $elem.find(".map_name").val(params.name);
70
9ec7e32e8ad3 working on maps
casties
parents: 69
diff changeset
105 layers = params.map_layers;
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
106 // remove old info
65
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
107 $(elem).find(".map_layer_table .layer_info").remove();
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
108 // write new info
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
109 if (layers.length > 0) {
72
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
110 $tmpl = $elem.find(".layer_info_tmpl").tmpl(layers);
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
111 $elem.find(".map_layer_header").after($tmpl);
69
752ce3dfd23e working on maps
casties
parents: 68
diff changeset
112 // arm edit and delete buttons
70
9ec7e32e8ad3 working on maps
casties
parents: 69
diff changeset
113 for (i = 0; i < layers.length; ++i) {
9ec7e32e8ad3 working on maps
casties
parents: 69
diff changeset
114 lp = layers[i].layer;
9ec7e32e8ad3 working on maps
casties
parents: 69
diff changeset
115 idx = layers[i].idx;
9ec7e32e8ad3 working on maps
casties
parents: 69
diff changeset
116 console.debug("showmapparams lp=", lp, " idx=", idx);
72
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
117 $tmpl.find(".layer_edit_"+idx).click(function () {
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
118 var param = lp;
70
9ec7e32e8ad3 working on maps
casties
parents: 69
diff changeset
119 console.debug("open layer ",idx);
72
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
120 blocks.addLayerBlock("blocks/layer.html?table="+escape(lp.table),"layer", param);
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
121 });
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
122 $tmpl.find(".layer_delete_"+idx).click(function () {
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
123 var layerIdx = idx;
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
124 console.debug("del layer ",layerIdx);
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
125 params = block.deleteMapLayer(layerIdx);
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
126 block.showMapParams(elem, params);
237
35c3d0ce2914 show line and polygon-layer
fknauft
parents: 236
diff changeset
127 var map = block.updateMap(elem, params);
70
9ec7e32e8ad3 working on maps
casties
parents: 69
diff changeset
128 });
9ec7e32e8ad3 working on maps
casties
parents: 69
diff changeset
129 }
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
130 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
131 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
132
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
133 guiBlocks.Block.prototype.readMapParams = function(elem,params) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
134 // read layer parameters from html element and store in param
68
49fb47bbe2e6 saving and loading maps
casties
parents: 67
diff changeset
135 if (elem == null) {
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
136 elem = this.element;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
137 }
68
49fb47bbe2e6 saving and loading maps
casties
parents: 67
diff changeset
138 if (params == null) {
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
139 params = this.params;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
140 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
141 params.name = $(elem).find(".map_name").val();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
142 var layers = params.map_layers;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
143 for (var i = 0; i < layers.length; i++) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
144 layers[i].display = $(elem).find(".layer_display_"+i).attr("checked");
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
145 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
146 //params.position_field = $(elem).find(".map_position_select").val();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
147 //params.connect_line = $(elem).find(".layer_line_checkbox").attr("checked");
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
148 return params;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
149 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
150
253
d6c7bedf4370 New reload button active in upper right corner of block
fknauft
parents: 249
diff changeset
151 guiBlocks.Block.prototype.reloadMap = function(elem) {
d6c7bedf4370 New reload button active in upper right corner of block
fknauft
parents: 249
diff changeset
152 if (elem == null) {
d6c7bedf4370 New reload button active in upper right corner of block
fknauft
parents: 249
diff changeset
153 elem = this.element;
d6c7bedf4370 New reload button active in upper right corner of block
fknauft
parents: 249
diff changeset
154 }
243
f842728b16a1 show line and polygon-layer
fknauft
parents: 242
diff changeset
155 /*var center = map.getCenter();
240
5159df776eaf show line and polygon-layer
fknauft
parents: 239
diff changeset
156 var dummymarker = new google.maps.Marker();
5159df776eaf show line and polygon-layer
fknauft
parents: 239
diff changeset
157 dummymarker.setPosition(center);
5159df776eaf show line and polygon-layer
fknauft
parents: 239
diff changeset
158 dummymarker.setVisible(false);
5159df776eaf show line and polygon-layer
fknauft
parents: 239
diff changeset
159 dummymarker.setMap(map);
243
f842728b16a1 show line and polygon-layer
fknauft
parents: 242
diff changeset
160 */
242
f64a779e9458 show line and polygon-layer
fknauft
parents: 241
diff changeset
161 console.debug("map: ", map);
241
b5d9237ca4d7 show line and polygon-layer
fknauft
parents: 240
diff changeset
162 console.debug("map reloaded");
240
5159df776eaf show line and polygon-layer
fknauft
parents: 239
diff changeset
163
237
35c3d0ce2914 show line and polygon-layer
fknauft
parents: 236
diff changeset
164 };
35c3d0ce2914 show line and polygon-layer
fknauft
parents: 236
diff changeset
165
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
166 guiBlocks.Block.prototype.updateMap = function(elem,map_params) {
226
0a1dee507612 general commit
fknauft
parents: 159
diff changeset
167
0a1dee507612 general commit
fknauft
parents: 159
diff changeset
168 //************
242
f64a779e9458 show line and polygon-layer
fknauft
parents: 241
diff changeset
169 console.debug("updateMap:", elem, ", ", map_params);
226
0a1dee507612 general commit
fknauft
parents: 159
diff changeset
170 //*************
0a1dee507612 general commit
fknauft
parents: 159
diff changeset
171
0a1dee507612 general commit
fknauft
parents: 159
diff changeset
172 if (elem == null) {
65
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
173 elem = this.element;
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
174 }
68
49fb47bbe2e6 saving and loading maps
casties
parents: 67
diff changeset
175 if (map_params == null) {
65
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
176 map_params = this.params;
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
177 }
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
178 // update and draw the google map
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
179 var le = $(elem).find(".map_box").get(0);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
180 // create empty map
226
0a1dee507612 general commit
fknauft
parents: 159
diff changeset
181
68
49fb47bbe2e6 saving and loading maps
casties
parents: 67
diff changeset
182 if (google != null) {
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
183 var latlng = new google.maps.LatLng(29, 116);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
184 var mapOpts = {
231
0a3303682712 Upload of xml-tables with empty Cells possible
fknauft
parents: 229
diff changeset
185 zoom: 2,
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
186 center: latlng,
244
57f0dfaf5949 show line and polygon-layer
fknauft
parents: 243
diff changeset
187 mapTypeId: google.maps.MapTypeId.TERRAIN,
57f0dfaf5949 show line and polygon-layer
fknauft
parents: 243
diff changeset
188 scaleControl: true
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
189 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
190 var map = new google.maps.Map(le, mapOpts);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
191 console.debug("new google map=",map," on el=",le);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
192 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
193 // add the layers
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
194 var layerList = map_params.map_layers;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
195 for (var i = 0; i < layerList.length; i++) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
196 if (!layerList[i].display) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
197 continue;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
198 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
199 var params = layerList[i].layer;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
200 var paramstr = "format=KML_URL";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
201 if (params.position_field && params.position_field != "Default") {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
202 paramstr += "&gis_id_field="+params.position_field;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
203 }
159
3dc6be23494c map layers with custom colors
fknauft
parents: 72
diff changeset
204 if (params.color_field != "Default") {
3dc6be23494c map layers with custom colors
fknauft
parents: 72
diff changeset
205 paramstr += "&color_field="+params.color_field;
3dc6be23494c map layers with custom colors
fknauft
parents: 72
diff changeset
206 }
3dc6be23494c map layers with custom colors
fknauft
parents: 72
diff changeset
207 if (params.geometry_field != "Default") {
3dc6be23494c map layers with custom colors
fknauft
parents: 72
diff changeset
208 paramstr += "&geometry_field="+params.geometry_field;
3dc6be23494c map layers with custom colors
fknauft
parents: 72
diff changeset
209 }
249
bba7dd7b6b4c Layer gui reordered, point order can be defined
fknauft
parents: 245
diff changeset
210 if (params.sort_field != "Default") {
bba7dd7b6b4c Layer gui reordered, point order can be defined
fknauft
parents: 245
diff changeset
211 paramstr += "&sort_field="+params.sort_field;
bba7dd7b6b4c Layer gui reordered, point order can be defined
fknauft
parents: 245
diff changeset
212 }
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
213 if (params.connect_line) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
214 paramstr += "&connect_line="+params.connect_line;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
215 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
216 var layerurl = "../db/RESTdb/db/public/" + escape(params.table) + "?" + paramstr;
72
825a92d0ab10 fixed potential closure problem
casties
parents: 70
diff changeset
217 jQuery.get(layerurl, function (data, textStatus, XMLHttpRequest) {
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
218 // function after load kml url finished
234
6e6e78adb447 show line and polygon-layer
fknauft
parents: 231
diff changeset
219 console.debug("kml url loaded! this=", this );
6e6e78adb447 show line and polygon-layer
fknauft
parents: 231
diff changeset
220 console.debug(" data=", data );
236
52aa589f4c4d show line and polygon-layer
fknauft
parents: 235
diff changeset
221 console.debug(" data type=", typeof(data));
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
222 if (typeof(data) == "string") {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
223 var kmlURL = data;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
224 } else {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
225 // broken, what now?
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
226 return;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
227 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
228 // render layer
68
49fb47bbe2e6 saving and loading maps
casties
parents: 67
diff changeset
229 if (google != null) {
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
230 var newMarker=new google.maps.KmlLayer(kmlURL);
245
7c5d825a0083 show line and polygon-layer
fknauft
parents: 244
diff changeset
231 console.debug("new marker layer no",i,"=",newMarker);
234
6e6e78adb447 show line and polygon-layer
fknauft
parents: 231
diff changeset
232 console.debug(" map=",map);
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
233 newMarker.setMap(map);
234
6e6e78adb447 show line and polygon-layer
fknauft
parents: 231
diff changeset
234 console.debug("Map-Update finished");
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
235 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
236 });
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
237 }
237
35c3d0ce2914 show line and polygon-layer
fknauft
parents: 236
diff changeset
238 return map;
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
239 };
65
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
240
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
241 guiBlocks.Block.prototype.addMapLayer = function(elem,params) {
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
242 var block = this;
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
243 // show list of layers, select and add to map
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
244 var layerList = [];
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
245 var $dlg = $(elem).find(".dialog.add_layer_select");
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
246 var $sel = $dlg.find("select.add_layer_select");
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
247 // fill list of layers
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
248 blocks.loadListOfItems("test1", "layer", function(data) {
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
249 console.debug("add layer list of items=",data);
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
250 layerList = data;
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
251 $sel.empty();
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
252 for (var i=0; i < data.length; i++) {
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
253 var key = data[i].key;
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
254 var val = data[i].val;
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
255 var name = val.name;
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
256 console.debug("layer",i," key=",key," value=",name);
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
257 $sel.append('<option value="'+key+'">'+name+'</option>');
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
258 }
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
259 });
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
260 console.debug("dlg=",$dlg);
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
261 $dlg.dialog({
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
262 buttons: {
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
263 "Ok": function() {
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
264 var layerName = $(this).find(".add_layer_select").val();
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
265 $(this).dialog("close");
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
266 var layerParams = jQuery.grep(layerList, function(x){return (x.key == layerName);})[0].val;
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
267 console.debug("addlayerok params=",layerParams);
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
268 params = block.appendMapLayer(layerParams);
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
269 block.showMapParams(elem, params);
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
270 params = block.readMapParams();
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
271 block.updateMap(elem,params);
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
272 },
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
273 "Cancel": function() {
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
274 $(this).dialog("close");
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
275 }
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
276 }
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
277 });
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
278 };
2f477270cc0c adding layers to maps works now
casties
parents: 63
diff changeset
279