~hsiung0911/sahana-eden/test

« back to all changes in this revision

Viewing changes to views/gis/unused/ol_controls_features_unused.js

  • Committer: eliao
  • Date: 2010-08-01 09:56:45 UTC
  • Revision ID: eliao@ibm-l3bw307-20100801095645-gsq9wcmjan0o0tby
This is my change

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// We add the controls in mf_toolbar.js
 
2
 
 
3
// Add control to add new points to the map.
 
4
pointControl = new OpenLayers.Control.DrawFeature(featuresLayer, OpenLayers.Handler.Point);
 
5
pointControl.featureAdded = shn_gis_map_create_feature;
 
6
map.addControl(pointControl);
 
7
 
 
8
// Add control to add new lines to the map.
 
9
lineControl = new OpenLayers.Control.DrawFeature(featuresLayer, OpenLayers.Handler.Path);
 
10
lineControl.featureAdded = shn_gis_map_create_feature;
 
11
map.addControl(lineControl);
 
12
 
 
13
// Add control to add new polygons to the map.
 
14
polygonControl = new OpenLayers.Control.DrawFeature(featuresLayer, OpenLayers.Handler.Polygon);
 
15
polygonControl.featureAdded = shn_gis_map_create_feature;
 
16
map.addControl(polygonControl);
 
17
 
 
18
// Add control to select features (showing info popup).
 
19
selectControl = new OpenLayers.Control.SelectFeature(featuresLayer, {
 
20
    onSelect: onFeatureSelect_1,
 
21
    onUnselect: onFeatureUnselect_1,
 
22
    multiple: false,
 
23
    clickout: true,
 
24
    toggle: true
 
25
});
 
26
map.addControl(selectControl);
 
27
 
 
28
// Supports feature select control.
 
29
function onFeatureSelect_1(feature){
 
30
    // Set global for back referencing
 
31
    currentFeature = feature;
 
32
    if (feature.popup.map == null) {
 
33
        map.addPopup(feature.popup);
 
34
        feature.popup.show();
 
35
    } else {
 
36
        feature.popup.toggle();
 
37
    }
 
38
}
 
39
// Supports feature select control.
 
40
function onFeatureUnselect_1(feature) {
 
41
    feature.popup.hide();
 
42
}
 
43
 
 
44
 
 
45
 
 
46
// Add control to drag internal features around the map.
 
47
// unused currently (will need to be careful about icon clash with Map pan/drag!)
 
48
dragControl = new OpenLayers.Control.DragFeature(featuresLayer, {
 
49
    onComplete: shn_gis_popup_edit_position
 
50
});
 
51
//map.addControl(dragControl);
 
52
 
 
53
// Called by dragControl after editing a Features position
 
54
function shn_gis_popup_edit_position(feature, pixel)
 
55
{
 
56
    xmlHttp = GetXmlHttpObject();
 
57
    if (xmlHttp==null){
 
58
        alert ("Your browser does not support AJAX!");
 
59
        return;
 
60
    }
 
61
    currentFeature = feature;
 
62
    // Move features popup to new location
 
63
    feature.popup.lonlat = feature.geometry.getBounds().getCenterLonLat();
 
64
    // Need id before clone
 
65
    var id  = feature.fid.substring(6)
 
66
    // Clone to stop any effects on the current feature.
 
67
    var cfcopy = feature.clone();
 
68
    // Transform for db.
 
69
    var lonlat = cfcopy.geometry.getBounds().getCenterLonLat().clone();
 
70
    var proj_current = map.getProjectionObject();
 
71
    lonlat.transform(proj_current, proj4326);
 
72
    var lat = lonlat.lat;
 
73
    var lon = lonlat.lon;
 
74
    var wkt = cfcopy.geometry.transform(proj_current, proj4326).toString();
 
75
    // Send to db
 
76
    //ToDo: =URL(r=request,c='gis',f='feature',args=['create'],vars=dict(format='json')
 
77
    var url='index.php?act=gis_popup_edit_position&mod=xst&stream=text&id=' + id;
 
78
    url = url + "&center_lat=" + lat + "&center_lon=" + lon + "&wkt=" + wkt;
 
79
    url = url +"&sid=" + Math.random();
 
80
    //xmlHttp.onreadystatechange = shn_gis_popup_print;
 
81
    xmlHttp.open("GET", url, true);
 
82
    xmlHttp.send(null);
 
83
}
 
84
 
 
85
// Add control to modify the shape of internal features on the map.
 
86
// WARNING this seems to cause select feature to behaviour strangely 
 
87
//(eg being able to drag a selected feature even if modify is disabled)
 
88
//modifyControl = new OpenLayers.Control.ModifyFeature(featuresLayer);
 
89
//map.addControl(modifyControl);
 
90
//modifyControl.mode = OpenLayers.Control.ModifyFeature.RESHAPE;
 
91
//modifyControl.mode &= ~OpenLayers.Control.ModifyFeature.DRAG;
 
92
 
 
93
// Start with select activated.
 
94
// unused_ol_controls_switch.js
 
95
//shn_gis_map_control_select();
 
 
b'\\ No newline at end of file'