-<% if defined? ID_KEY %>
- <div id="map">
- <iframe frameBorder="0" id="id-embed" class="id-embed" allowfullscreen></iframe>
- </div>
- <script>
- var params = {};
-
- function getParams(params) {
- var mapParams = OSM.mapParams();
- if (mapParams.object) {
- params.id = mapParams.object.type[0] + mapParams.object.id;
- mapParams = OSM.parseHash(location.hash);
- if (mapParams.center) {
- params.map = mapParams.zoom + '/' + mapParams.center.lat + '/' + mapParams.center.lng;
- }
- } else {
- params.map = (mapParams.zoom || 17) + '/' + mapParams.lat + '/' + mapParams.lon;
- }
- }
-
- getParams(params);
-
-<% if @lat && @lon -%>
- params.map = '16/<%= @lat %>/<%= @lon %>';
-<% end -%>
-
- var hashParams = OSM.params(location.hash.substring(1));
-
- if (hashParams.background) {
- params.background = hashParams.background;
- }
- if (hashParams.comment) {
- params.comment = hashParams.comment;
- }
- if (hashParams.offset) {
- params.offset = hashParams.offset;
- }
-
-<% if params[:gpx] -%>
- params.gpx = '<%= trace_data_url(params[:gpx], :format => :xml) %>';
-<% else -%>
- if (hashParams.gpx) {
- params.gpx = hashParams.gpx;
- }
-<% end -%>
-
- var baseUrl = '<%= id_url :locale => params[:locale] %>#';
-
- $('#id-embed').attr('src', baseUrl + querystring.stringify(params));
-
- $(window).on('hashchange', function () {
- getParams(params);
- $('#id-embed').attr('src', baseUrl + querystring.stringify(params));
- });
- </script>
-<% else %>
- <script type="text/javascript">alert("<%= t 'site.edit.id_not_configured' %>")</script>
-<% end %>
+<%= javascript_include_tag "edit/id" %>
+
+<div id="map" class="h-100 overflow-hidden">
+ <% data = { :configured => Settings.key?(:id_application) }
+ data[:lat] = @lat if @lat
+ data[:lon] = @lon if @lon
+ data[:gpx] = trace_data_url(params[:gpx], :format => :xml) if params[:gpx]
+ data[:url] = id_url(:locale => params[:locale]) %>
+ <%= tag.iframe "", :frameBorder => 0, :id => "id-embed", :class => "w-100 h-100", :allowfullscreen => "", :data => data %>
+</div>