Ticket #13926: openlayers.patch

File openlayers.patch, 4.0 KB (added by anonymous, 14 years ago)

Patch for real.

Line 
1*** openlayers-dist.js 2010-07-12 13:36:38.222527172 -0400
2--- openlayers.js 2010-07-12 13:32:37.246532160 -0400
3***************
4*** 18,24 ****
5 return {{ module }}.wkt_f.read(wkt);
6 }
7 {{ module }}.write_wkt = function(feat){
8! if ({{ module }}.is_collection){ {{ module }}.num_geom = feat.geometry.components.length;}
9 else { {{ module }}.num_geom = 1;}
10 document.getElementById('{{ id }}').value = {{ module }}.get_ewkt(feat);
11 }
12--- 17,23 ----
13 return {{ module }}.wkt_f.read(wkt);
14 }
15 {{ module }}.write_wkt = function(feat){
16! if ({{ module }}.is_collection){ {{ module }}.num_geom = feat.length;}
17 else { {{ module }}.num_geom = 1;}
18 document.getElementById('{{ id }}').value = {{ module }}.get_ewkt(feat);
19 }
20***************
21*** 117,146 ****
22 // Read WKT from the text field.
23 var wkt = document.getElementById('{{ id }}').value;
24 if (wkt){
25! // After reading into geometry, immediately write back to
26 // WKT <textarea> as EWKT (so that SRID is included).
27 var admin_geom = {{ module }}.read_wkt(wkt);
28 {{ module }}.write_wkt(admin_geom);
29 if ({{ module }}.is_collection){
30! // If geometry collection, add each component individually so they may be
31! // edited individually.
32! for (var i = 0; i < {{ module }}.num_geom; i++){
33! {{ module }}.layers.vector.addFeatures([new OpenLayers.Feature.Vector(admin_geom.geometry.components[i].clone())]);
34! }
35 } else {
36! {{ module }}.layers.vector.addFeatures([admin_geom]);
37 }
38 // Zooming to the bounds.
39! {{ module }}.map.zoomToExtent(admin_geom.geometry.getBounds());
40 if ({{ module }}.is_point){
41! {{ module }}.map.zoomTo({{ point_zoom }});
42 }
43 } else {
44 {{ module }}.map.setCenter(new OpenLayers.LonLat({{ default_lon }}, {{ default_lat }}), {{ default_zoom }});
45 }
46 // This allows editing of the geographic fields -- the modified WKT is
47 // written back to the content field (as EWKT, so that the ORM will know
48! // to transform back to original SRID).
49 {{ module }}.layers.vector.events.on({"featuremodified" : {{ module }}.modify_wkt});
50 {{ module }}.layers.vector.events.on({"featureadded" : {{ module }}.add_wkt});
51 {% block controls %}
52--- 112,149 ----
53 // Read WKT from the text field.
54 var wkt = document.getElementById('{{ id }}').value;
55 if (wkt){
56! // After reading into geometry, immediately write back to
57 // WKT <textarea> as EWKT (so that SRID is included).
58 var admin_geom = {{ module }}.read_wkt(wkt);
59 {{ module }}.write_wkt(admin_geom);
60 if ({{ module }}.is_collection){
61! // If geometry collection, add each component individually so they may be
62! // edited individually.
63! for (var i = 0; i < {{ module }}.num_geom; i++){
64! {{ module }}.layers.vector.addFeatures([new OpenLayers.Feature.Vector(admin_geom[i].geometry.clone())]);
65! }
66 } else {
67! {{ module }}.layers.vector.addFeatures([admin_geom]);
68 }
69 // Zooming to the bounds.
70! if ({{ module }}.is_collection) {
71! var bounds = new OpenLayers.Bounds();
72! for (var i = 0; i < {{ module }}.num_geom; i++) {
73! bounds.extend(admin_geom[i].geometry.getBounds());
74! }
75! {{ module }}.map.zoomToExtent(bounds);
76! } else {
77! {{ module }}.map.zoomToExtent(admin_geom.geometry.getBounds());
78! }
79 if ({{ module }}.is_point){
80! {{ module }}.map.zoomTo({{ point_zoom }});
81 }
82 } else {
83 {{ module }}.map.setCenter(new OpenLayers.LonLat({{ default_lon }}, {{ default_lat }}), {{ default_zoom }});
84 }
85 // This allows editing of the geographic fields -- the modified WKT is
86 // written back to the content field (as EWKT, so that the ORM will know
87! // to transform back to original SRID).
88 {{ module }}.layers.vector.events.on({"featuremodified" : {{ module }}.modify_wkt});
89 {{ module }}.layers.vector.events.on({"featureadded" : {{ module }}.add_wkt});
90 {% block controls %}
Back to Top