Modified JavaScript to allow passing of lat, lon and zoom into page in URL query.
[potlatch2.git] / resources / potlatch2.html
1 <html>
2
3 <!-- Potlatch 2 script -->
4
5 <head>
6 <title>Potlatch TWO</title>
7 <script type="text/javascript" src="swfobject.js"></script>
8 </head>
9
10 <body>
11
12 <div id="map" style="width:100%; height: 100%; border: 1px solid black">
13 </div>
14
15 <script>
16         function getArgs() {
17                 var args = new Object();
18                 var query = location.search.substring(1);
19                 var pairs = query.split("&");
20                 for(var i = 0; i < pairs.length; i++) {
21                         var pos = pairs[i].indexOf('=');
22                         if (pos == -1) continue;
23                         var argname = pairs[i].substring(0,pos);
24                         var value = pairs[i].substring(pos+1);
25                         args[argname] = unescape(value);
26                 }
27                 return args;
28         }
29
30         var args = getArgs();
31         var lat;
32         var lon;
33         var zoom;
34         if (args.lat && args.lon) {
35                 lat = parseFloat(args.lat);
36                 lon = parseFloat(args.lon);
37         } else {
38                 lat=51.875;
39                 lon=-1.492;
40         }
41
42         if (args.zoom) {
43                 zoom = parseInt(args.zoom);
44         } else {
45                 zoom = 16;
46         }
47
48         var fo = new SWFObject("potlatch2.swf?d="+Math.round(Math.random()*1000), "map", "100%", "100%", "9", "#FFFFFF");
49         fo.addVariable("lat",lat);
50         fo.addVariable("lon",lon);
51         fo.addVariable("zoom",zoom);
52         fo.addVariable("api","http://api06.dev.openstreetmap.org/api/0.6/");
53         fo.addVariable("policy","http://api06.dev.openstreetmap.org/api/crossdomain.xml");
54         fo.addVariable("connection","XML");
55         fo.addVariable("oauth_policy", "http://api06.dev.openstreetmap.org/oauth/crossdomain.xml");
56         fo.addVariable("oauth_request_url", "http://api06.dev.openstreetmap.org/oauth/request_token");
57         fo.addVariable("oauth_access_url", "http://api06.dev.openstreetmap.org/oauth/access_token");
58         fo.addVariable("oauth_auth_url", "http://api06.dev.openstreetmap.org/oauth/authorize");
59         fo.addVariable("oauth_consumer_key", "fiM1IoqnKJk4JCfcl63DA");
60         fo.addVariable("oauth_consumer_secret", "7fYgJK9M4vB1CvBZ6jEsPGxYK9UD1hEnI6NqTxNGs");
61         fo.addVariable("serverName", "api06 Test On Dev");
62         fo.write("map");
63
64
65 </script>
66
67 </body>
68 </html>
69