annotate gis_gui/blocks/layer.js @ 102:a0838591e83f

changable color for dots in map
author fknauft
date Tue, 01 Feb 2011 16:38:33 +0100
parents 49fb47bbe2e6
children 06309d0702de
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
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2 guiBlocks.prototype.addLayerBlock = function(url, baseId, params) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3 if (typeof(params) == "string") {
68
49fb47bbe2e6 saving and loading maps
casties
parents: 63
diff changeset
4 // then its the table name
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5 params = {"type": "layer", "table": params};
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
6 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
7 var block = this.addBlock(url, baseId, params, function() {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
8 // function after add block finished
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
9 var id = block.id;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
10 var be = block.element;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
11 block.type = "layer";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
12 var tablename = params.table;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
13 console.debug("in layerblock after block load!");
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
14 $(be).find(".layer_name").val(block.params.name);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
15 $(be).find(".layer_position_select").load("../db/RESTdb/db/public/"+tablename+"?format=HTML&type=schema_table_rows&layout=select&element_id=rows #rows *",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
16 function() {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
17 $(this).find("option:first").before('<option>Default</option>');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
18 if (!params.position_field) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
19 params.position_field = "Default";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
20 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
21 $(this).find("option").filter(function(){return $(this).text() == params.position_field;}).attr("selected","true");
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 $(be).find(".layer_label_select").load("../db/RESTdb/db/public/"+tablename+"?format=HTML&type=schema_table_rows&layout=select&element_id=rows #rows *",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
24 function() {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
25 $(this).find("option:first").before('<option>Default</option>');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
26 if (!params.label_field) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
27 params.label_field = "Default";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
28 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
29 $(this).find("option").filter(function(){return $(this).text() == params.label_field;}).attr("selected","true");
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
30 });
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
31 $(be).find(".layer_size_select").load("../db/RESTdb/db/public/"+tablename+"?format=HTML&type=schema_table_rows&layout=select&element_id=rows #rows *",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
32 function() {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
33 $(this).find("option:first").before('<option>Default</option>');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
34 if (!params.size_field) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
35 params.size_field = "Default";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
36 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
37 $(this).find("option").filter(function(){return $(this).text() == params.size_field;}).attr("selected","true");
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
38 });
102
a0838591e83f changable color for dots in map
fknauft
parents: 68
diff changeset
39 $(be).find(".layer_color_select");
a0838591e83f changable color for dots in map
fknauft
parents: 68
diff changeset
40 // $(be).find(".layer_color_select").load("../db/RESTdb/db/public/"+tablename+"?format=HTML&type=schema_table_rows&layout=select&element_id=rows #rows *",
a0838591e83f changable color for dots in map
fknauft
parents: 68
diff changeset
41 // function() {
a0838591e83f changable color for dots in map
fknauft
parents: 68
diff changeset
42 // $(this).find("option:first").before('<option>Default</option>');
a0838591e83f changable color for dots in map
fknauft
parents: 68
diff changeset
43 // if (!params.color_field) {
a0838591e83f changable color for dots in map
fknauft
parents: 68
diff changeset
44 // params.color_field = "Default";
a0838591e83f changable color for dots in map
fknauft
parents: 68
diff changeset
45 // }
a0838591e83f changable color for dots in map
fknauft
parents: 68
diff changeset
46 // $(this).find("option").filter(function(){return $(this).text() == params.color_field;}).attr("selected","true");
a0838591e83f changable color for dots in map
fknauft
parents: 68
diff changeset
47 // });
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
48 $(be).find(".layer_shape_select").load("../db/RESTdb/db/public/"+tablename+"?format=HTML&type=schema_table_rows&layout=select&element_id=rows #rows *",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
49 function() {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
50 $(this).find("option:first").before('<option>Default</option>');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
51 if (!params.shape_field) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
52 params.shape_field = "Default";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
53 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
54 $(this).find("option").filter(function(){return $(this).text() == params.shape_field;}).attr("selected","true");
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
55 });
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
56 $(be).find(".layer_line_checkbox").attr("checked", params.connect_line);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
57 // show block
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
58 $(be).fadeIn();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
59
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
60 // save map params in block.param -- too early
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
61 //params = block.readLayerParams();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
62
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
63 // load map
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
64 block.updateLayer(be,params);
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 // update button
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
67 $(be).find(".layer_update_button").click(function() {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
68 console.debug("layer update");
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
69 params = block.readLayerParams();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
70 block.updateLayer(be,params);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
71 });
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
72 // save button
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
73 $(be).find(".layer_save_button").click(function() {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
74 console.debug("layer save. this=",this," block=",block);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
75 params = block.readLayerParams(be,params);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
76 block.storeBlock("test1");
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
77 });
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
78 // open table button
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
79 $(be).find(".layer_open_table_button").click(function() {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
80 console.debug("layer open table. this=",this," block=",block);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
81 var tblblock = blocks.addTableBlock("blocks/table.html?table="+escape(params.table),"table", params.table);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
82 });
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
83 // create map button
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
84 $(be).find(".map_create_button").click(function() {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
85 console.debug("layer create map. this=",this," block=",block);
68
49fb47bbe2e6 saving and loading maps
casties
parents: 63
diff changeset
86 var mapblock = blocks.addMapBlock("blocks/map.html?layer="+escape(params.name),"map",null,params);
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
87 });
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
88
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
89 });
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
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
92 guiBlocks.Block.prototype.readLayerParams = function(elem,params) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
93 // read layer parameters from html element and store in param
68
49fb47bbe2e6 saving and loading maps
casties
parents: 63
diff changeset
94 if (elem == null) {
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
95 elem = this.element;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
96 }
68
49fb47bbe2e6 saving and loading maps
casties
parents: 63
diff changeset
97 if (param == null) {
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
98 params = this.params;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
99 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
100 params.name = $(elem).find(".layer_name").val();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
101 params.position_field = $(elem).find(".layer_position_select").val();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
102 params.label_field = $(elem).find(".layer_label_select").val();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
103 params.size_field = $(elem).find(".layer_size_select").val();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
104 params.color_field = $(elem).find(".layer_color_select").val();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
105 params.shape_field = $(elem).find(".layer_shape_select").val();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
106 params.connect_line = $(elem).find(".layer_line_checkbox").attr("checked");
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
107 return params;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
108 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
109
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
110 guiBlocks.Block.prototype.updateLayer = function(elem,params) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
111 // update and draw the google map
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
112 var le = $(elem).find(".map_box").get(0);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
113 var paramstr = "format=KML_URL";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
114 if (params.position_field && params.position_field != "Default") {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
115 paramstr += "&gis_id_field="+params.position_field;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
116 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
117 if (params.connect_line) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
118 paramstr += "&connect_line="+params.connect_line;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
119 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
120 var layerurl = "../db/RESTdb/db/public/" + escape(params.table) + "?" + paramstr;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
121 jQuery.get(layerurl, function(data, textStatus, XMLHttpRequest) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
122 // function after load kml url finished
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
123 console.debug("kml url loaded! this=", this, " data=", data, " ("+typeof(data)+")");
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
124 if (typeof(data) == "string") {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
125 var kmlURL = data;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
126 } else {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
127 // what to do?
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
128 return;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
129 }
68
49fb47bbe2e6 saving and loading maps
casties
parents: 63
diff changeset
130 if (google != null) {
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
131 var latlng = new google.maps.LatLng(29, 116);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
132 var mapOpts = {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
133 zoom: 5,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
134 center: latlng,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
135 mapTypeId: google.maps.MapTypeId.TERRAIN
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
136 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
137 var map = new google.maps.Map(le, mapOpts);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
138 console.debug("new google map=",map," on el=",le);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
139
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
140 //geocoder = new google.maps.Geocoder();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
141 var newMarker=new google.maps.KmlLayer(kmlURL);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
142 console.debug("new marker layer=",newMarker);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
143 newMarker.setMap(map);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
144 }
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
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
147 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
148