summaryrefslogtreecommitdiff
path: root/libs/js/jquery-geo-1.0a4/docs/examples/geometry.html
diff options
context:
space:
mode:
Diffstat (limited to 'libs/js/jquery-geo-1.0a4/docs/examples/geometry.html')
-rwxr-xr-xlibs/js/jquery-geo-1.0a4/docs/examples/geometry.html133
1 files changed, 133 insertions, 0 deletions
diff --git a/libs/js/jquery-geo-1.0a4/docs/examples/geometry.html b/libs/js/jquery-geo-1.0a4/docs/examples/geometry.html
new file mode 100755
index 00000000..890fdc7a
--- /dev/null
+++ b/libs/js/jquery-geo-1.0a4/docs/examples/geometry.html
@@ -0,0 +1,133 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>proj test</title>
+ <meta name="description" content="Small test of $.geo.proj">
+ <meta name="author" content="Ryan Westphal">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <link rel="stylesheet" type="text/css" href="css/style.css" />
+ <style type="text/css">
+ label
+ {
+ display: block;
+ margin: .25em;
+ }
+ label span
+ {
+ display: inline-block;
+ font-weight: bold;
+ width: 8em;
+ }
+ #lblStatus
+ {
+ background: #ee4;
+ border-radius: .5em;
+ padding: .5em;
+ }
+ </style>
+</head>
+<body>
+ <div>
+ <a href="../" class="docLink">&lt; docs</a>
+ <h1>
+ proj test</h1>
+ <p>
+ This page has a couple basic interactive tests of the default $.geo.proj object.</p>
+ <h2>
+ direct conversion</h2>
+ <p>
+ Enter a lon/lat in the top inputs (remember, longitude is first here and throughout jQuery Geo but usually spoken second) &amp; click fromGeodetic to convert it to web mercator and store the new values in the bottom two inputs. Click toGeodetic to reverse.</p>
+ <label>
+ <span>longitude</span>
+ <input type="text" id="txtLon" value="-71.0597732" />
+ </label>
+ <label>
+ <span>latitude</span>
+ <input type="text" id="txtLat" value="42.3584308" />
+ </label>
+ <button type="button" id="cmdFrom">
+ \/ fromGeodetic</button>
+ <button type="button" id="cmdTo">
+ /\ toGeodetic</button>
+ <label>
+ <span>web mercator x</span>
+ <input type="text" id="txtX" value="-7910337.768509507" />
+ </label>
+ <label>
+ <span>web mercator y</span>
+ <input type="text" id="txtY" value="5214822.77694091" />
+ </label>
+ <h2>
+ osm nominatim</h2>
+ <p>
+ Enter a search term in the input and click search. If successful, geodetic &amp; web mercator coordinates are written to the inputs above. This example uses MapQuest's OSM API: <a href="http://open.mapquestapi.com/nominatim/">http://open.mapquestapi.com/nominatim</a>.</p>
+ <label>
+ <span>query</span>
+ <input type="text" id="txtQuery" value="Boston,MA" />
+ </label>
+ <button type="button" id="cmdSearch">search</button>
+ <h2>
+ status</h2>
+ <p>
+ Status result for any test.</p>
+ <div id="lblStatus">
+ ready</div>
+ </div>
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
+ <script src="http://code.jquerygeo.com/jquery.geo-1.0a4.min.js"></script>
+ <script>
+ $(function () {
+ $("#cmdFrom").click(function () {
+ try {
+ var projected = $.geo.proj.fromGeodetic([[parseFloat($("#txtLon").val()), parseFloat($("#txtLat").val())]]);
+ $("#txtX").val(projected[0][0])
+ $("#txtY").val(projected[0][1])
+ $("#lblStatus").html("done " + (new Date()).toString());
+ } catch (e) {
+ $("#lblStatus").html("error" + e.toString());
+ }
+ });
+ $("#cmdTo").click(function () {
+ try {
+ var geodetic = $.geo.proj.toGeodetic([[parseFloat($("#txtX").val()), parseFloat($("#txtY").val())]]);
+ $("#txtLon").val(geodetic[0][0])
+ $("#txtLat").val(geodetic[0][1])
+ $("#lblStatus").html("done " + (new Date()).toString());
+ } catch (e) {
+ $("#lblStatus").html("error" + e.toString());
+ }
+ });
+
+ $("#cmdSearch").click(function () {
+ try {
+ var query = "http://open.mapquestapi.com/nominatim/v1/search?format=json&q=" + $("#txtQuery").val();
+ $.ajax({
+ url: query,
+ dataType: "jsonp",
+ jsonp: "json_callback",
+ success: function (result) {
+ if (result && result.length > 0) {
+ $("#txtLon").val(result[0].lon)
+ $("#txtLat").val(result[0].lat)
+ var projected = $.geo.proj.fromGeodetic([[result[0].lon, result[0].lat]]);
+ $("#txtX").val(projected[0][0])
+ $("#txtY").val(projected[0][1])
+ $("#lblStatus").html("done " + (new Date()).toString());
+ } else {
+ $("#lblStatus").html("nothing found :(");
+ }
+ },
+ error: function (xhr) {
+ $("#lblStatus").html(xhr.statusText);
+ }
+ });
+ } catch (e) {
+ $("#lblStatus").html("error" + e.toString());
+ }
+ });
+ });
+ </script>
+</body>
+</html>
+