]> git.openstreetmap.org Git - rails.git/blob - app/views/site/id_iframe.html.erb
Call updatelinks when map moves
[rails.git] / app / views / site / id_iframe.html.erb
1 <!DOCTYPE html>
2 <html>
3 <head>
4   <meta charset='utf-8'>
5   <%= stylesheet_link_tag 'iD' %>
6   <!--[if !IE || gte IE 9]><!-->
7   <%= javascript_include_tag 'iD' %>
8   <!-- <![endif]-->
9 </head>
10 <body>
11 <div id='id-container'></div>
12 <script>
13   if (typeof iD == 'undefined') {
14     document.getElementById('id-container').innerHTML = 'This editor is supported ' +
15       'in Firefox, Chrome, Safari, Opera, and Internet Explorer 9 and above. ' +
16       'Please upgrade your browser or use Potlatch 2 to edit the map.';
17     document.getElementById('id-container').className = 'unsupported';
18   } else {
19     var id = iD()
20       .embed(true)
21       .imagePath("/assets/iD/img/")<%# Can't use asset_path('id/img/') in production. %>
22       .preauth({
23         <% token = @user.access_token(ID_KEY) %>
24         url: "<%= request.protocol + request.host_with_port %>",
25         oauth_consumer_key: "<%= token.client_application.key %>",
26         oauth_secret: "<%= token.client_application.secret %>",
27         oauth_token: "<%= token.token %>",
28         oauth_token_secret: "<%= token.secret %>"
29       });
30
31     id.map().on('move.embed', function() {
32       var extent = id.map().extent(),
33           zoom = ~~id.map().zoom(),
34           center = id.map().center();
35
36       parent.updatelinks(
37         center[0],
38         center[1],
39         zoom,
40         null,
41         extent[0][0],
42         extent[0][1],
43         extent[1][0],
44         extent[1][1]);
45     });
46
47     d3.select('#id-container')
48       .call(id.ui());
49   }
50 </script>
51 </body>
52 </html>