- Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathResetFieldDB.html
More file actions
Latest commit
85 lines (80 loc) · 2.57 KB
/
Copy pathResetFieldDB.html
File metadata and controls
85 lines (80 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<html>
<head>
<title>Learning Geospatial Analysis with Python 2nd Ed. Field Data Collection Example "Database" Reset</title>
<metaname="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<style>
body {
padding:0;
margin:0;
background-color:#000000;
color:#FFFFFF;
font-family: Verdana, Arial, Sans-serif;
}
html,body,#map {
height:80%;
}
h1,h2,h3,h4{
color:#FFFFFF;
font-family: Verdana, Arial, Sans-serif;
}
#info {
background-color:#FFFF00;
color:#FF0000;
font-family: Verdana, Arial, Sans-serif;
}
</style>
</head>
<bodyonload="retrieveData()">
<div>
<h3>Field Data Collection Example "Database" Reset</h3>
<fontcolor="#009933">Learning Geospatial Analysis with Python 2nd Ed.</font>
<p>
This page resets the simple MyJSON.com storage for this cookbook example to a single geojson feature to fix the inevitable
<ahref="http://www.joelonsoftware.com/articles/fog0000000319.html">Shlemiel problem</a> with this simple design. This approach
keeps this example as simple and understandable as possible.</p>
</div>
<divid="form">
<formid="dbReset">
<inputtype="button" value="RESET" onclick="sendData()"><br/>
</form>
<b>Current stored geojson contents:</b><br/>
</div>
<divid="currentDb">
</div>
<script>
varmyJsonUrl='https://api.myjson.com/bins/3ztvz';
vardatabase='';
info='';
functionretrieveData(){
varxhr=newXMLHttpRequest();
xhr.open("GET",myJsonUrl+"?pretty=1",false);
xhr.send(null);
data=xhr.responseText;
info=document.getElementById("currentDb");
info.innerHTML="<pre>"+data+"</pre>";
}
functionsendData(){
frm_name=document.getElementById("name");
frm_date=document.getElementById("date");
frm_comment=document.getElementById("comment");
observation={"type": "FeatureCollection",
"crs": {"type": "name",
"properties": {"name": "urn:ogc:def:crs:OGC:1.3:CRS84"}},
"features": [
{"type": "Feature",
"properties": {"popupContent": "NAME: Joel Lawhead<br> DATE: 2015-11-2<br> COMMENT: No ice found."},
"geometry": {"type": "Point",
"coordinates": [-101.467289719626166,39.596844824675088]}}
]};
varxhr=newXMLHttpRequest();
xhr.open("PUT",myJsonUrl,true);
xhr.setRequestHeader('Content-Type','application/json; charset=UTF-8');
// update the collected data as JSON
obs=JSON.stringify(observation);
xhr.send(obs);
info.innerHTML="<pre>"+obs+"</pre>";
}
</script>
</body>
</html>