summaryrefslogtreecommitdiff
path: root/libs/js/jquery-geo-1.0a4/docs/examples/wkt.html
blob: 20200b70b5abcbfdd2a5f39e61a625c806d96cf7 (plain)
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
<!DOCTYPE html>
<html>
<head>
  <title>WKT parse/stringify example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1">
  <meta name="description" content="An example of WKT parse/stringify">
  <meta name="author" content="Ryan Westphal">
  <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/blitzer/jquery-ui.css" />
  <link rel="stylesheet" type="text/css" href="css/style.css" />
  <style type="text/css">
    #map
    {
      position: fixed;
      left: 0;
      top: 0;
      right: 0;
      bottom: 0;
    }
  </style>
</head>
<body>
  <div>
    <div id="map">
    </div>
    <div class="info">
      <a href="../" class="docLink">&lt; docs</a>
      <h1>
        WKT parse &amp; stringify</h1>
      <p>
        This example uses $.geo.WKT.stringify to turn your drawn GeoJSON objects into WKT. The Parse button uses $.geo.WKT.parse to read valid WKT from the text box and add shapes to the map.</p>
      <textarea id="wkt" rows="4" cols="32"></textarea>
      <button id="parse" type="button">Parse</button>
      <button id="clear" type="button">Reset</button>
    </div>
  </div>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
  <script src="http://code.jquerygeo.com/jquery.geo-1.0a4.min.js"></script>
  <script>
    $(function () {
      var map = $("#map").geomap({
        center: [-71.0595678, 42.3604823],
        zoom: 8,
        click: function (e, geo) {
          $("#wkt").val($.geo._WKT.stringify(geo));
          map.geomap("append", geo);
        }
      });

      $.geo.proj = null;

      $("#parse").button().click(function (e) {
        var geo = $.geo._WKT.parse($("textarea").val());
        if (geo) {
          map.geomap("append", geo);
        }
      });

      $("#clear").button().click(function (e) {
        $("textarea").val("");
        map.geomap("empty");
      });
    });  
  </script>

  <script>
    var _gaq = [['_setAccount', 'UA-26084853-1'], ['_trackPageview']];
    (function (d, t) {
      var g = d.createElement(t), s = d.getElementsByTagName(t)[0]; g.async = 1;
      g.src = ('https:' == location.protocol ? '//ssl' : '//www') + '.google-analytics.com/ga.js';
      s.parentNode.insertBefore(g, s);
    } (document, 'script'));
  </script>
</body>
</html>