annotate gis_gui/blocks/map.js @ 270:3a5d51c60e40

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