Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
James Halliday
committed
Jan 28, 2016
1 parent
e2e558a
commit a4f3ff5
Showing
6 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
example/*/bundle.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<body> | ||
<h1>add point</h1> | ||
<form id="add"> | ||
<table> | ||
<tr> | ||
<th>lat</th> | ||
<td><input type="text" name="lat"></td> | ||
</tr> | ||
<tr> | ||
<th>lon</th> | ||
<td><input type="text" name="lon"></td> | ||
</tr> | ||
</table> | ||
<button type="submit">add point</button> | ||
</form> | ||
<hr> | ||
<h1>query</h1> | ||
<form id="query"> | ||
<table> | ||
<tr> | ||
<th>lat</th> | ||
<td>min=<input type="text" name="minlat"></td> | ||
<td>max=<input type="text" name="maxlat"></td> | ||
</tr> | ||
<tr> | ||
<th>lon</th> | ||
<td>min=<input type="text" name="minlon"></td> | ||
<td>max=<input type="text" name="maxlon"></td> | ||
</tr> | ||
</table> | ||
<button type="submit">query</button> | ||
<pre id="query-results"></pre> | ||
</form> | ||
<script src="bundle.js"></script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
var osmdb = require('../../') | ||
var osm = osmdb() | ||
|
||
document.querySelector('form#add').addEventListener('submit', onadd) | ||
document.querySelector('form#query').addEventListener('submit', onquery) | ||
|
||
function onadd (ev) { | ||
var form = this | ||
ev.preventDefault() | ||
var doc = { | ||
lat: this.elements.lat.value, | ||
lon: this.elements.lon.value | ||
} | ||
osm.create(doc, function (err, key, node) { | ||
if (err) console.error(err) | ||
else form.reset() | ||
}) | ||
} | ||
|
||
function onquery (ev) { | ||
ev.preventDefault() | ||
var q = [ | ||
[ this.elements.minlat.value, this.elements.maxlat.value ], | ||
[ this.elements.minlon.value, this.elements.maxlon.value ] | ||
] | ||
osm.query(q, function (err, results) { | ||
document.querySelector('#query-results').innerText | ||
= results.map(str).join('\n') | ||
function str (row) { return JSON.stringify(row) } | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"scripts": { | ||
"build": "browserify main.js > bundle.js", | ||
"watch": "watchify main.js -o bundle.js -dv", | ||
"start": "ecstatic -p 8000 ." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,3 +49,7 @@ $ node osm.js query 61,65 -149,-147 | |
``` | ||
|
||
# browser example | ||
|
||
``` js | ||
``` | ||
|