1
<!-- File to be included in a form which needs to be able to add a new feature to the database via map entry -->
3
<div class='message information'>
4
You can move around and enlarge/reduce the size of the area you want using the scale on upper left corner of the map.<br>
5
By clicking on the map you can mark your location with a pointer..
8
<div id="outer_map" style="width: 600px; height: 800px; background-color: #FFFFFF">
9
<div id='gis_map_toolbar' >
10
<fieldset id='gis_map_toolbar_fieldset' style="border: 1px solid ; padding: 5px; padding-bottom:2px;">
11
<div id="gis_map_toolbar_default">
12
<span title="Expand Map"><a onclick="shn_gis_map_expand()" alt="Full screen map"><div id="gis_map_icon_expand" style="width: 24px; height: 22px;"></div></a></span>
14
<div id="gis_map_toolbar_manipulate">
15
<span title="Navigate"><a onclick="shn_gis_map_control_navigate()" alt="Navigate"><div id="gis_map_icon_select" style="width: 24px; height: 22px;"></div></a></span>
16
<span title="Add Point"><a onclick="shn_gis_map_control_add_point()" alt="Add Point"><div id="gis_map_icon_addpoint" style="width: 24px; height: 22px;"></div></a></span>
17
<span title="Add Line"><a onclick="shn_gis_map_control_add_line()" alt="Add Line"><div id="gis_map_icon_addline" style="width: 24px; height: 22px;"></div></a></span>
18
<span title="Add Area"><a onclick="shn_gis_map_control_add_polygon()" alt="Add Area"><div id="gis_map_icon_addpolygon" style="width: 24px; height: 22px;"></div></a></span>
19
<span title="Toggle Freehand Draw"><a onclick="shn_gis_map_control_freehand()" alt="Toggle Freehand Draw"><div id="gis_map_icon_freehand" style="width: 24px; height: 22px;"></div></a></span>
20
<span title="Mode Description" id="gis_map_icon_descripion"></span>
24
<div style="float: left; width: 100%;">
26
<div id="map" style="border: 2px solid black; background-color: #FFFFFF">
30
<script type="text/javascript">
32
// make map available for easy debugging
35
// make features available
36
var featuresLayer, currentFeature;
38
// Make Controls Available
47
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
48
OpenLayers.Util.onImageLoadErrorColor = "transparent";
51
OpenLayers.ProxyHost = '/sahana/static/proxy.py?url=';
57
// See - http://crschmidt.net/~crschmidt/spherical_mercator.html#reprojecting-points
58
var proj4326 = new OpenLayers.Projection("EPSG:4326");
59
var projection_current = new OpenLayers.Projection('EPSG:900913');
60
var point = new OpenLayers.LonLat(lon, lat);
64
displayProjection: proj4326,
65
projection: projection_current,
67
maxResolution: 156543.0339,
68
maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508.34),
69
//restrictedExtent: new OpenLayers.Bounds()
75
map = new OpenLayers.Map('map', options);
76
var mapnik = new OpenLayers.Layer.TMS( "OpenStreetMap (Mapnik)", "http://tile.openstreetmap.org/", {type: 'png', getURL: osm_getTileURL, displayOutsideMaxExtent: true } );
78
var wmslayer1 = new OpenLayers.Layer.WMS( "VMap0",
79
"http://labs.metacarta.com/wms/vmap0",
80
{layers:'basic', isBaseLayer:'true', wrapDateLine:'true'});
81
map.addLayer(wmslayer1);
82
featuresLayer = new OpenLayers.Layer.Vector("Feature");map.addLayer(featuresLayer);
83
map.addControl(new OpenLayers.Control.LayerSwitcher());
84
map.addControl(new OpenLayers.Control.PanZoomBar());
85
map.addControl(new OpenLayers.Control.ScaleLine());
86
map.addControl(new OpenLayers.Control.MousePosition());
87
map.addControl(new OpenLayers.Control.OverviewMap({mapOptions: options}));
89
// Add control to add new Points to the map.
90
pointControl = new OpenLayers.Control.DrawFeature(featuresLayer, OpenLayers.Handler.Point);
91
pointControl.featureAdded = shn_gis_map_add_geometry;
92
map.addControl(pointControl);
93
// Add control to add new Lines to the map.
94
lineControl = new OpenLayers.Control.DrawFeature(featuresLayer, OpenLayers.Handler.Path);
95
lineControl.featureAdded = shn_gis_map_add_geometry;
96
map.addControl(lineControl);
97
// Add control to add new Polygons to the map.
98
polygonControl = new OpenLayers.Control.DrawFeature(featuresLayer, OpenLayers.Handler.Polygon);
99
polygonControl.featureAdded = shn_gis_map_add_geometry;
100
map.addControl(polygonControl);
101
shn_gis_map_control_navigate(); // Center the map.
102
map.setCenter(point.transform(proj4326, map.getProjectionObject()), zoom);
104
window.onload(initMap());
105
function shn_gis_map_add_geometry(feature){
107
var fcopy = feature.clone();
109
var fcopygeom = fcopy.geometry.clone();
110
var lonlat = fcopy.geometry.getBounds().getCenterLonLat();
111
var proj_current = map.getProjectionObject();
112
lonlat.transform(proj_current, proj4326);
113
var lon_new = lonlat.lon;
114
var lat_new = lonlat.lat;
115
var wkt_new = fcopy.geometry.transform(proj_current, proj4326).toString();
116
var type_new = featureTypeStr(fcopy);
118
// Update form fields
119
var x_gps = document.getElementById("gps_x");
120
var y_gps = document.getElementById("gps_y");
121
if( x_gps != null && y_gps != null){
122
x_gps.value = lon_new;
123
y_gps.value = lat_new;
126
// store x,y coords in hidden variables named loc_x, loc_y
127
// must be set via calling page
128
var x_point = document.getElementsByName("loc_x");
129
var y_point = document.getElementsByName("loc_y");
130
if(x_point != null && y_point != null){
131
x_point[0].value = lon_new;
132
y_point[0].value = lat_new;
135
var loc_type = document.getElementsByName("loc_type");
136
if(loc_type != null){
137
loc_type[0].value = type_new;
140
var wkt_point = document.getElementsByName("loc_wkt");
141
if(wkt_point != null){
142
wkt_point[0].value = wkt_new;
145
// Remove last plot from layer
146
featuresLayer.destroyFeatures(featuresLayer.features);
149
add_Feature(featuresLayer, 'newFeature', fcopygeom, '/sahana/static/img/marker.png');
152
function add_Feature(layer, feature_id, geom, iconURL){
154
var icon_img = new Image();
155
icon_img.src = iconURL;
158
var width = icon_img.width;
159
var height = icon_img.height;
161
height = ((max_w / width) * height);
165
width = ((max_h / height) * width);
168
// http://www.nabble.com/Markers-vs-Features--td16497389.html
169
var style_marker = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
170
//style_mark.pointRadius = 12;
171
style_marker.graphicWidth = width;
172
style_marker.graphicHeight = height;
173
style_marker.graphicXOffset = -(width / 2);
174
style_marker.graphicYOffset = -height;
175
style_marker.externalGraphic = iconURL;
176
style_marker.graphicOpacity = 1;
177
// Create Feature Vector + Props
178
var featureVec = new OpenLayers.Feature.Vector(geom, null, style_marker);
179
featureVec.fid = feature_id;
181
layer.addFeatures([featureVec]);
183
// General functions usable by all Layers
185
// returns string type of a feature
186
// return point if not line or poly ....danger....
187
function featureTypeStr(feature){
189
var geotype = feature.geometry.CLASS_NAME;
190
if(geotype == 'OpenLayers.Geometry.LineString'){
192
} else if(geotype == 'OpenLayers.Geometry.Polygon'){
197
// create geometries from point coords.
198
function coordToGeom(coords, type){
201
geom = coords[0]; // = Array(new OpenLayers.Geometry.Point(lon, lat));
202
} else if(type == 'line'){
203
geom = new OpenLayers.Geometry.LineString(coords);
204
} else if(type == 'poly'){
205
geom = new OpenLayers.Geometry.Polygon(new Array(new OpenLayers.Geometry.LinearRing(coords)));
209
// Report Errors to a DIV
210
function ReportErrors(div,text) {
211
$(div).innerHTML = text;
214
function onFeatureUnselect(feature) {
215
map.removePopup(feature.popup);
216
feature.popup.destroy();
217
feature.popup = null;
219
// For OSM File layers
220
function on_feature_hover(feature) {
223
if (feature.geometry.CLASS_NAME == "OpenLayers.Geometry.Point") {
226
text += "<li>" + feature.osm_id + ": <a href='http://www.openstreetmap.org/api/0.5/"+type + "/" + feature.osm_id + "'>API</a></li>";
227
for (var key in feature.attributes) {
228
text += "<li>" + key + ": " + feature.attributes[key] + "</li>";
231
$("status_osm").innerHTML = text;
233
function osm_getTileURL(bounds) {
234
var res = this.map.getResolution();
235
var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
236
var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));
237
var z = this.map.getZoom();
238
var limit = Math.pow(2, z);
239
if (y < 0 || y >= limit) {
240
return OpenLayers.Util.getImagesLocation() + "404.png";
242
x = ((x % limit) + limit) % limit;
243
return this.url + z + "/" + x + "/" + y + "." + this.type;
246
// Activate Control for navigating around the maps.
247
function shn_gis_map_control_navigate(){
248
shn_gis_map_control_deactivate_all();
249
document.getElementById('gis_map_icon_select').style.backgroundImage = "url(/sahana/static/mfbase/openlayers/theme/default/img/move_feature_on.png)";
250
document.getElementById('gis_map_icon_descripion').innerHTML = 'Mode: Navigate';
252
// Activate Control for selecting features.
253
function shn_gis_map_control_select(){
254
shn_gis_map_control_deactivate_all();
255
document.getElementById('gis_map_icon_select').style.backgroundImage = "url(/sahana/static/mfbase/openlayers/theme/default/img/move_feature_on.png)";
256
document.getElementById('gis_map_icon_descripion').innerHTML = 'Mode: Select';
257
selectControl.activate();
259
// Activate Control for dragging features.
260
function shn_gis_map_control_drag(){
261
shn_gis_map_control_deactivate_all();
262
document.getElementById('gis_map_icon_drag').style.backgroundImage = "url(/sahana/static/mfbase/openlayers/theme/default/img/pan_on.png)";
263
document.getElementById('gis_map_icon_descripion').innerHTML = 'Mode: Drag';
264
dragControl.activate();
266
// Activate Control for modifying features.
267
function shn_gis_map_control_modify(){
268
shn_gis_map_control_deactivate_all();
269
//document.getElementById('gis_map_icon_modify').style.backgroundImage = "url()";
270
//document.getElementById('gis_map_icon_descripion').innerHTML = 'Mode: Modify';
271
//modifyControl.activate();
273
// Activate Control for adding point features.
274
function shn_gis_map_control_add_point(){
275
shn_gis_map_control_deactivate_all();
276
document.getElementById('gis_map_icon_addpoint').style.backgroundImage = "url(/sahana/static/mfbase/openlayers/theme/default/img/draw_point_on.png)";
277
document.getElementById('gis_map_icon_descripion').innerHTML = 'Mode: Add Point';
278
pointControl.activate();
280
// Activate Control for adding line features.
281
function shn_gis_map_control_add_line(){
282
shn_gis_map_control_deactivate_all();
283
document.getElementById('gis_map_icon_addline').style.backgroundImage = "url(/sahana/static/mfbase/openlayers/theme/default/img/draw_line_on.png)";
284
document.getElementById('gis_map_icon_descripion').innerHTML = 'Mode: Add line';
285
lineControl.activate();
287
// Activate Control for adding polygon features.
288
function shn_gis_map_control_add_polygon(){
289
shn_gis_map_control_deactivate_all();
290
document.getElementById('gis_map_icon_addpolygon').style.backgroundImage = "url(/sahana/static/mfbase/openlayers/theme/default/img/draw_polygon_on.png)";
291
document.getElementById('gis_map_icon_descripion').innerHTML = 'Mode: Add Area';
292
polygonControl.activate();
294
// Activate Control for drawing features freehand.
295
function shn_gis_map_control_freehand(){
296
if(lineControl.handler.freehand){
297
document.getElementById('gis_map_icon_freehand').style.backgroundImage = "url(/sahana/static/mfbase/openlayers/theme/default/img/freehand_off.png)";
298
document.getElementById('gis_map_icon_descripion').innerHTML = 'Mode: Freehand OFF';
299
lineControl.handler.freehand = false;
300
polygonControl.handler.freehand = false;
302
document.getElementById('gis_map_icon_freehand').style.backgroundImage = "url(/sahana/static/mfbase/openlayers/theme/default/img/freehand_on.png)";
303
document.getElementById('gis_map_icon_descripion').innerHTML = 'Mode: Freehand ON';
304
lineControl.handler.freehand = true;
305
polygonControl.handler.freehand = true;
308
// Deactivate all other controls
309
function shn_gis_map_control_deactivate_all(){
311
var nav = document.getElementById('gis_map_icon_select')
313
nav.style.backgroundImage = "url(/sahana/static/mfbase/openlayers/theme/default/img/move_feature_off.png)";
316
if(selectControl != null){
317
selectControl.unselectAll();
318
selectControl.deactivate();
319
document.getElementById('gis_map_icon_select').style.backgroundImage = "url(/sahana/static/mfbase/openlayers/theme/default/img/move_feature_off.png)";
322
if(dragControl != null){
323
dragControl.deactivate();
324
document.getElementById('gis_map_icon_drag').style.backgroundImage = "url(/sahana/static/mfbase/openlayers/theme/default/img/pan_off.png)";
327
//if(modifyControl != null){
328
//modifyControl.deactivate();
330
// Drop features/popups in progress from a create feature.
331
if(currentFeature != null && ((pointControl != null && pointControl.active) || (lineControl != null && lineControl.active) || (polygonControl != null && polygonControl.active))){
332
if(currentFeature.popup != null){
333
currentFeature.popup.hide();
334
currentFeature.popup.destroy(currentFeature.popup);
336
featuresLayer.removeFeatures([currentFeature]);
337
currentFeature.destroy();
338
currentFeature = null;
340
// Hide any popup showing and deactivate current feature.
341
if(currentFeature != null){
342
if(currentFeature.popup != null){
343
currentFeature.popup.hide();
345
currentFeature = null;
347
// Turn off point add
348
if(pointControl != null){
349
pointControl.deactivate();
350
document.getElementById('gis_map_icon_addpoint').style.backgroundImage = "url(/sahana/static/mfbase/openlayers/theme/default/img/draw_point_off.png)";
353
if(lineControl != null){
354
lineControl.deactivate();
355
document.getElementById('gis_map_icon_addline').style.backgroundImage = "url(/sahana/static/mfbase/openlayers/theme/default/img/draw_line_off.png)";
357
// Turn off polygon add
358
if(polygonControl != null){
359
polygonControl.deactivate();
360
document.getElementById('gis_map_icon_addpolygon').style.backgroundImage = "url(/sahana/static/mfbase/openlayers/theme/default/img/draw_polygon_off.png)";
363
function shn_gis_map_expand()
365
var omap = document.getElementById("outer_map");
366
var amap = document.getElementById("map");
367
var tmap = document.getElementById("gis_map_toolbar");
368
var fmap = document.getElementById("gis_map_toolbar_fieldset");
369
var expd = document.getElementById("gis_map_icon_expand");
370
// If currently small, make big
371
if(omap.style.position != 'fixed'){
372
expd.style.backgroundImage = "url(/sahana/static/mfbase/openlayers/theme/default/img/map_resize_in_c.png)";
373
amap.style.width = '100%';
374
amap.style.height = '100%';
375
omap.style.position = 'fixed';
376
omap.style.top = '0px';
377
omap.style.left = '0px';
378
omap.style.width = '100%';
379
omap.style.height = '100%';
380
omap.style.marginLeft = '0px';
381
fmap.style.border = '0px none';
382
tmap.style.margin = '0px';
384
// If currently big, make small
386
expd.style.backgroundImage = "url(/sahana/static/mfbase/openlayers/theme/default/img/map_resize_out_c.png)";
387
amap.style.width = '760px';
388
amap.style.height = '600px';
389
omap.style.position = 'relative';
390
omap.style.top = 'auto';
391
omap.style.left = 'auto';
392
omap.style.width = 'auto';
393
omap.style.height = 'auto';
394
omap.style.marginLeft = '10px';
395
fmap.style.border = '1px solid';
396
tmap.style.margin = '10px 10px 10px 0px';
399
// On Creating a new feature Display a popup box to enter details.
400
function shn_gis_map_create_feature(feature){
401
// If adding a new popup before an old one is completed, kill old popup (current feature is set to null at end of process)
402
if(currentFeature != null){
403
currentFeature.popup.hide();
404
featuresLayer.removeFeatures([currentFeature]);
405
currentFeature.popup.destroy(currentFeature.popup);
406
currentFeature.destroy();
408
// Generate Popup + Props
410
var fc_lonlat = feature.geometry.getBounds().getCenterLonLat();
412
var fc_contentHTML = "<div class='gis_openlayers_popupbox' id='popup_'><form method='post' action='index.php?mod=admin&act=gis_database_classes_edit' id='form0' name='form0'><input name='seq' value='seq_3' type='hidden' /> <div class='gis_openlayers_popupbox_header'> <div class='gis_openlayers_popupbox_header_r'> <div class='gis_openlayers_popupbox_author'><label for='gis_popup_author' >Author:</label> <input type='text' name='gis_popup_author' id='popup__popup_auth' size='15' maxlength='60' tabindex=8 /></div> <div class='gis_openlayers_popupbox_date'><label for='gis_popup_date' >Date:</label> <input type='text' name='gis_popup_date' id='popup__popup_edate' size='15' tabindex=9 /></div> </div> <div class='gis_openlayers_popupbox_header_l'> <div class='gis_openlayers_popupbox_name'><label for='gis_popup_name'>Name:</label> <span><input type='text' name='gis_popup_name' id='popup__popup_name' size='10' maxlength='60' tabindex=6 /></span> ()</div> <div class='gis_openlayers_popupbox_url'><label for='gis_popup_name'>Url:</label> <input type='text' name='gis_popup_url' id='popup__popup_url' size='40' maxlength='100' tabindex=7 /></div> </div> <div class='gis_openlayers_popupbox_address'><b>Address:</b> <input type='text' name='gis_popup_address' id='popup__popup_add' size='55' maxlength='200' tabindex=10 /></div> </div> <div class='gis_openlayers_popupbox_body'> <span class='gis_openlayers_popupbox_text'><textarea rows='5' cols='70' name='gis_popup_desc' id='popup__popup_desc' tabindex=11 ></textarea></span> </div> <div class='gis_openlayers_popupbox_footer'> <span><a onclick='shn_gis_popup_new_cancel('popup_')' alt='cancel'><div class='gis_openlayers_popupbox_edit_cancel' style='width: 17px; height: 17px;'></div><span>cancel</span></a></span> <span><a onclick='shn_gis_popup_new_ok('popup_')' alt='ok'><div class='gis_openlayers_popupbox_edit_ok' style='width: 17px; height: 17px;'></div><span>ok</span></a></span> </div> <div style='clear: both;'></div></form></div>";
413
var fc_anchor = null;
414
var fc_closeBox = true; // Bad can close without create...
415
var fc_closeBoxCallback = shn_gis_popup_new_cancel;
416
var framedCloud = new OpenLayers.Popup.FramedCloud(fc_id, fc_lonlat, fc_size, fc_contentHTML, fc_anchor, fc_closeBox, fc_closeBoxCallback);
417
framedCloud.autoSize = true;
418
framedCloud.minSize = new OpenLayers.Size(460,270);
420
feature.popup = framedCloud;
421
map.addPopup(feature.popup);
422
feature.popup.show();
423
currentFeature = feature;
425
// Supports feature select control.
426
function onFeatureSelect_1(feature){
427
// Set global for back referencing
428
currentFeature = feature;
429
if (feature.popup.map == null) {
430
map.addPopup(feature.popup);
431
feature.popup.show();
433
feature.popup.toggle();
436
// Supports feature select control.
437
function onFeatureUnselect_1(feature) {
438
feature.popup.hide();
440
// Supports feature select control.
441
function onPopupClose(evt) {
442
onFeatureUnselect_1(currentFeature);
445
function shn_gis_popup_unable()
447
alert ("The module that created this feature does not support this action here. Navigate to the module manually to perform this action.");
449
function shn_gis_popup_print()
451
if (xmlHttp.readyState == 4){
452
var textDoc = xmlHttp.responseText;
453
currentFeature.popup.setContentHTML(textDoc);
456
function shn_gis_popup_refresh_print()
458
if (xmlHttp.readyState == 4){
459
var textDoc = xmlHttp.responseText;
460
if(textDoc == '<delete />'){
461
currentFeature.popup.hide();
462
featuresLayer.removeFeatures([currentFeature]);
463
currentFeature.popup.destroy(currentFeature.popup);
464
currentFeature.destroy();
465
//featuresLayer.redraw();
467
currentFeature.popup.setContentHTML(textDoc);
471
function shn_gis_popup_new_print()
473
if (xmlHttp.readyState == 4){
474
var textDoc = xmlHttp.responseText;
476
var geom = currentFeature.geometry.clone();
478
currentFeature.popup.hide();
479
featuresLayer.removeFeatures([currentFeature]);
480
currentFeature.popup.destroy(currentFeature.popup);
481
currentFeature.destroy();
482
currentFeature = null;
483
//featuresLayer.redraw();
484
if(!(textDoc == 'fail' || textDoc == '')){
485
var uuidpos = textDoc.search('<uuid />');
486
var iconURLPos = textDoc.search('<icon />');
488
var uuid = textDoc.substring(0, uuidpos);
489
var iconURL = textDoc.substring((uuidpos + 8), iconURLPos);
490
var html = textDoc.substring((iconURLPos + 8));
492
add_Feature_with_popup(featuresLayer, uuid, geom, html, iconURL);
494
alert("Failed to create new Feature.");
498
// Called by link in popup box
499
function shn_gis_popup_new_ok(id){
500
xmlHttp = GetXmlHttpObject();
502
alert ("Your browser does not support AJAX!");
505
// Clone to stop any effects on the current feature.
506
var cfcopy = currentFeature.clone();
507
// returns string type of a feature
508
// return point if not line or poly ....danger....
509
var type = featureTypeStr(cfcopy);
511
var lonlat = cfcopy.geometry.getBounds().getCenterLonLat().clone();
512
var proj_current = map.getProjectionObject();
513
lonlat.transform(proj_current, proj4326);
514
var lat = lonlat.lat;
515
var lon = lonlat.lon;
516
var wkt = cfcopy.geometry.transform(proj_current, proj4326).toString();
517
var name = document.getElementById(id + '_popup_name').value;
518
var desc = document.getElementById(id + '_popup_desc').value;
519
var auth = document.getElementById(id + '_popup_auth').value;
520
var furl = document.getElementById(id + '_popup_url').value;
521
var add = document.getElementById(id + '_popup_add').value;
522
var edate = document.getElementById(id + '_popup_edate').value;
524
var url = 'index.php?act=gis_popup_new_ok&mod=xst&stream=text';
525
url = url + "&type=" + type + "¢er_lat=" + lat + "¢er_lon=" + lon + "&wkt=" + wkt + "&name=" + name + "&desc=" + desc + "&auth=" + auth + "&url=" + furl + "&add=" + add + "&date=" + edate;
526
url = url + "&sid=" + Math.random();
527
xmlHttp.onreadystatechange = shn_gis_popup_new_print;
528
xmlHttp.open("GET", url, true);
531
// Called by link in popup box
532
function shn_gis_popup_new_cancel(){
533
currentFeature.popup.hide();
534
featuresLayer.removeFeatures([currentFeature]);
535
currentFeature.popup.destroy(currentFeature.popup);
536
currentFeature.destroy();
537
currentFeature = null;
539
// Called by link in popup box
540
function shn_gis_popup_refresh(id)
542
xmlHttp = GetXmlHttpObject();
543
if (xmlHttp == null){
544
alert ("Your browser does not support AJAX!");
548
var url = 'index.php?act=gis_popup_refresh&mod=xst&stream=text&id=' + id;
549
url = url +"&sid=" + Math.random();
550
xmlHttp.onreadystatechange = shn_gis_popup_refresh_print;
551
xmlHttp.open("GET", url, true);
554
// Called by link in popup box
555
function shn_gis_popup_delete(id)
557
xmlHttp = GetXmlHttpObject();
558
if (xmlHttp == null){
562
ok = confirm("Are you sure you wish to Delete Feature from system");
564
var url = 'index.php?act=gis_popup_delete&mod=xst&stream=text&id=' + id;
565
url = url +"&sid=" + Math.random();
566
xmlHttp.onreadystatechange = shn_gis_popup_refresh_print;
567
xmlHttp.open("GET", url, true);
571
// Called by dragControl after editing a Features position
572
function shn_gis_popup_edit_position(feature, pixel)
574
xmlHttp = GetXmlHttpObject();
576
alert ("Your browser does not support AJAX!");
579
currentFeature = feature;
580
// Move features popup to new location
581
feature.popup.lonlat = feature.geometry.getBounds().getCenterLonLat();
582
// Need id before clone
583
var id = feature.fid.substring(6)
584
// Clone to stop any effects on the current feature.
585
var cfcopy = feature.clone();
587
var lonlat = cfcopy.geometry.getBounds().getCenterLonLat().clone();
588
var proj_current = map.getProjectionObject();
589
lonlat.transform(proj_current, proj4326);
590
var lat = lonlat.lat;
591
var lon = lonlat.lon;
592
var wkt = cfcopy.geometry.transform(proj_current, proj4326).toString();
594
var url='index.php?act=gis_popup_edit_position&mod=xst&stream=text&id=' + id;
595
url = url + "¢er_lat=" + lat + "¢er_lon=" + lon + "&wkt=" + wkt;
596
url = url +"&sid=" + Math.random();
597
//xmlHttp.onreadystatechange = shn_gis_popup_print;
598
xmlHttp.open("GET", url, true);
601
// Called by link in popup box
602
function shn_gis_popup_edit_details(id)
604
xmlHttp = GetXmlHttpObject();
606
alert ("Your browser does not support AJAX!");
609
var url='index.php?act=gis_popup_edit_details&mod=xst&stream=text&id=' + id;
610
url = url +"&sid=" + Math.random();
611
xmlHttp.onreadystatechange = shn_gis_popup_print;
612
xmlHttp.open("GET", url, true);
615
function shn_gis_popup_edit_details_ok(id)
617
xmlHttp = GetXmlHttpObject();
619
alert ("Your browser does not support AJAX!");
622
var name = document.getElementById(id + '_popup_name').value;
623
var desc = document.getElementById(id + '_popup_desc').value;
624
var auth = document.getElementById(id + '_popup_auth').value;
625
var furl = document.getElementById(id + '_popup_url').value;
626
var add = document.getElementById(id + '_popup_add').value;
627
var edate = document.getElementById(id + '_popup_edate').value;
628
var url = 'index.php?act=gis_popup_edit_details_ok&mod=xst&stream=text&id=' + id;
629
url = url + "&name=" + name + "&desc=" + desc + "&auth=" + auth + "&url=" + furl + "&add=" + add + "&date=" + edate;
630
url = url +"&sid=" + Math.random();
631
xmlHttp.onreadystatechange = shn_gis_popup_print;
632
xmlHttp.open("GET", url, true);
635
function GetXmlHttpObject(){
638
// Firefox, Opera 8.0+, Safari
639
xmlHttp=new XMLHttpRequest();
644
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
647
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
654
<div id="center"></div>
656
{{include 'gis/ol_status.html'}}