]> git.openstreetmap.org Git - rails.git/blob - app/views/site/edit.rhtml
Use IP GeoLocation to choose a default view for the slippy map if
[rails.git] / app / views / site / edit.rhtml
1 <% if API_READONLY %>
2 <p>The OpenStreetMap database is currently in read-only mode while
3    essential database maintenance work is carried out.
4 </p>
5 <% else %>
6 <%= render :partial => 'search', :locals => { :onopen => "resizeMap();", :onclose => "resizeMap();" } %>
7
8 <% if params['mlon'] and params['mlat'] %>
9 <% lon =  params['mlon'] %>
10 <% lat =  params['mlat']  %>
11 <% zoom =  params['zoom'] || '12' %>
12 <% elsif @user and params['lon'].nil? and params['lat'].nil? %> 
13 <% lon =  @user.home_lon %>
14 <% lat =  @user.home_lat %>
15 <% zoom = '12' %>
16 <%else%>
17 <% lon =  params['lon'] || '-0.1' %>
18 <% lat =  params['lat'] || '51.5' %>
19 <% zoom =  params['zoom'] || '12' %>
20 <% end %>
21
22 <div id="map">You need a Flash player to use Potlatch, the
23     OpenStreetMap Flash editor. You can <a href="http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">download Flash Player from Adobe.com</a>.
24
25     <a href="http://wiki.openstreetmap.org/index.php/Editing">Several other options</a> are also available
26     for editing OpenStreetMap.
27 </div>
28 <script type="text/javascript" src="/javascripts/swfobject.js"></script>
29 <script type="text/javascript">
30   var brokenContentSize = $("content").offsetWidth == 0;
31   var fo = new SWFObject("/potlatch/potlatch.swf?d="+Math.round(Math.random()*1000), "potlatch", "700", "600", "6", "#FFFFFF");
32
33   function doSWF(lat,lon,sc) {
34     fo.addVariable('lat',lat);
35     fo.addVariable('long',lon);
36     fo.addVariable('scale',sc);
37     fo.addVariable('token','<%= @user.token %>');
38     fo.write("map");
39   }
40
41   doSWF(<%= lat %>,<%= lon %>,<%= zoom %>);
42
43   function setPosition(lat, lon, zoom) {
44     doSWF(lat, lon, zoom);
45   }
46
47   function resizeContent() {
48     var content = $("content");
49     var rightMargin = parseInt(getStyle(content, "right"));
50     var bottomMargin = parseInt(getStyle(content, "bottom"));
51
52     content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
53     content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
54   }
55   
56   function resizeMap() {
57     var search_results_width = $("search_results").offsetWidth;
58
59     if (search_results_width > 0) {
60       search_results_width = search_results_width + 5
61     }
62
63     $("map").style.left = (search_results_width) + "px";
64     $("map").style.width = ($("content").offsetWidth - search_results_width) + "px";
65     $("map").style.height = ($("content").offsetHeight - 2) + "px";
66   }
67
68   function handleResize() {
69     if (brokenContentSize) {
70       resizeContent();
71     }
72
73     resizeMap();
74   }
75
76   window.onresize = handleResize;
77   window.onload = handleResize;
78 </script>
79 <% end %>