annotate gis_gui/blocks/map.js @ 239:95721c5afd0b

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