1 <%= javascript_include_tag 'openlayers.js' %>
2 <%= javascript_include_tag 'map.js' %>
4 <iframe id="linkloader" style="display: none">
8 <% if map.instance_of? Changeset or (map.instance_of? Node and map.version > 1) or map.visible %>
11 <span id="loading"><%= t 'browse.map.loading' %></span>
12 <%= link_to(t("browse.map.larger.area"), { :controller => :site, :action => :index, :box => "yes" }, { :id => "area_larger_map", :class => "geolink bbox" }) %>
14 <%= link_to(h(t("browse.map.edit.area")) + content_tag(:span, "▾", :class => "menuicon"), { :controller => :site, :action => :edit }, { :id => "area_edit", :class => "geolink bbox" }) %>
15 <% unless map.instance_of? Changeset %>
17 <%= link_to(t("browse.map.larger." + map.class.to_s.downcase), { :controller => :site, :action => :index }, { :id => "object_larger_map", :class => "geolink object" }) %>
19 <%= link_to(h(t("browse.map.edit." + map.class.to_s.downcase)) + content_tag(:span, "▾", :class => "menuicon"), { :controller => :site, :action => :edit }, { :id => "object_edit", :class => "geolink object" }) %>
22 <%= t 'browse.map.deleted' %>
26 <div id="area_edit_menu" class="menu">
28 <% Editors::ALL_EDITORS.each do |editor| %>
29 <li><%= link_to t('layouts.edit_with', :editor => t("editor.#{editor}.description")), { :controller => :site, :action => :edit, :editor => editor }, { :id => "#{editor}_area_edit", :class => "geolink bbox" } %></li>
34 <div id="object_edit_menu" class="menu">
36 <% Editors::ALL_EDITORS.each do |editor| %>
37 <li><%= link_to t('layouts.edit_with', :editor => t("editor.#{editor}.description")), { :controller => :site, :action => :edit, :editor => editor }, { :id => "#{editor}_object_edit", :class => "geolink object" } %></li>
42 <% if map.instance_of? Changeset or (map.instance_of? Node and map.version > 1) or map.visible %>
43 <script type="text/javascript">
44 OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
46 function remoteEditHandler(event, bbox, select) {
47 var left = bbox.left - 0.0001;
48 var top = bbox.top + 0.0001;
49 var right = bbox.right + 0.0001;
50 var bottom = bbox.bottom - 0.0001;
53 $("#linkloader").load(function () { loaded = true; });
56 $("#linkloader").attr("src", "http://127.0.0.1:8111/load_and_zoom?left=" + left + "&top=" + top + "&right=" + right + "&bottom=" + bottom + "&select=" + select);
58 $("#linkloader").attr("src", "http://127.0.0.1:8111/load_and_zoom?left=" + left + "&top=" + top + "&right=" + right + "&bottom=" + bottom);
61 setTimeout(function () {
62 if (!loaded) alert("<%=j t('site.index.remote_failed') %>");
69 var map = createMap("small_map", {
70 controls: [ new OpenLayers.Control.Navigation() ]
73 <% if map.instance_of? Changeset -%>
74 <% bbox = map.bbox.to_unscaled %>
75 var minlon = <%= bbox.min_lon %>;
76 var minlat = <%= bbox.min_lat %>;
77 var maxlon = <%= bbox.max_lon %>;
78 var maxlat = <%= bbox.max_lat %>;
79 var bbox = new OpenLayers.Bounds(minlon, minlat, maxlon, maxlat);
80 var centre = bbox.getCenterLonLat();
82 map.zoomToExtent(proj(bbox));
86 $("#browse_map .geolink").show();
88 $("#remote_area_edit").click(function (event) {
89 return remoteEditHandler(event, bbox);
92 <% if preferred_editor == "remote" -%>
93 $("#area_edit").click(function (event) {
94 return remoteEditHandler(event, bbox);
98 updatelinks(centre.lon, centre.lat, 16, null, minlon, minlat, maxlon, maxlat);
100 var obj_type = "<%= map.class.name.downcase %>";
101 var obj_id = <%= map.id %>;
102 var obj_version = <%= map.version %>;
103 var obj_visible = <%= map.visible %>;
104 var url = "/api/<%= API_VERSION %>/<%= map.class.name.downcase %>/<%= map.id %>";
106 if (obj_type != "node") {
108 } else if (!obj_visible) {
109 var previous_version = obj_version - 1;
110 url += "/" + previous_version;
113 $("#object_larger_map").hide();
114 $("#object_edit").hide();
116 addObjectToMap(url, true, function(extent) {
117 $("#loading").hide();
118 $("#browse_map .geolink").show();
121 extent.transform(map.getProjectionObject(), map.displayProjection);
123 var centre = extent.getCenterLonLat();
125 $("#remote_area_edit").click(function (event) {
126 return remoteEditHandler(event, extent);
129 <% if preferred_editor == "remote" -%>
130 $("#area_edit").click(function (event) {
131 return remoteEditHandler(event, extent);
135 $("#remote_object_edit").click(function (event) {
136 return remoteEditHandler(event, extent, "<%= map.class.to_s.downcase + map.id.to_s %>");
139 <% if preferred_editor == "remote" -%>
140 $("#object_edit").click(function (event) {
141 return remoteEditHandler(event, extent, "<%= map.class.to_s.downcase + map.id.to_s %>");
145 $("#object_larger_map").show();
146 $("#object_edit").show();
148 updatelinks(centre.lon, centre.lat, 16, null, extent.left, extent.bottom, extent.right, extent.top, "<%= map.class.to_s.downcase %>", <%= map.id %>);
150 $("#small_map").hide();
155 createMenu("area_edit", "area_edit_menu", "right");
156 createMenu("object_edit", "object_edit_menu", "right");
159 window.onload = init;