1 <iframe id="linkloader" style="display: none">
5 <% if map.instance_of? Changeset or (map.instance_of? Node and map.version > 1) or map.visible? %>
8 <span id="loading"><%= t 'browse.map.loading' %></span>
9 <% if map.instance_of? Note -%>
10 <%= link_to(t("browse.map.larger.area"), { :controller => :site, :action => :index, :notes => "yes" }, { :id => "area_larger_map", :class => "geolink bbox" }) %>
12 <%= link_to(t("browse.map.larger.area"), { :controller => :site, :action => :index, :box => "yes" }, { :id => "area_larger_map", :class => "geolink bbox" }) %>
15 <%= link_to(h(t("browse.map.edit.area")) + content_tag(:span, "▾", :class => "menuicon"), { :controller => :site, :action => :edit }, { :id => "area_edit", :class => "geolink bbox" }) %>
16 <% unless map.instance_of? Changeset or map.instance_of? Note %>
18 <%= link_to(t("browse.map.larger." + map.class.to_s.downcase), { :controller => :site, :action => :index }, { :id => "object_larger_map", :class => "geolink object" }) %>
20 <%= 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" }) %>
23 <%= t 'browse.map.deleted' %>
27 <div id="area_edit_menu" class="menu">
29 <% Editors::ALL_EDITORS.each do |editor| %>
30 <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>
35 <div id="object_edit_menu" class="menu">
37 <% Editors::ALL_EDITORS.each do |editor| %>
38 <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>
43 <% if map.instance_of? Changeset or (map.instance_of? Node and map.version > 1) or map.visible? %>
44 <script type="text/javascript">
45 function remoteEditHandler(event, bbox, select) {
46 var left = bbox.left - 0.0001;
47 var top = bbox.top + 0.0001;
48 var right = bbox.right + 0.0001;
49 var bottom = bbox.bottom - 0.0001;
52 $("#linkloader").load(function () { loaded = true; });
55 $("#linkloader").attr("src", "http://127.0.0.1:8111/load_and_zoom?left=" + left + "&top=" + top + "&right=" + right + "&bottom=" + bottom + "&select=" + select);
57 $("#linkloader").attr("src", "http://127.0.0.1:8111/load_and_zoom?left=" + left + "&top=" + top + "&right=" + right + "&bottom=" + bottom);
60 setTimeout(function () {
61 if (!loaded) alert("<%=j t('site.index.remote_failed') %>");
68 var map = createMap("small_map", {
69 controls: [ new OpenLayers.Control.Navigation() ]
72 <% if map.instance_of? Changeset -%>
73 <% bbox = map.bbox.to_unscaled %>
74 var minlon = <%= bbox.min_lon %>;
75 var minlat = <%= bbox.min_lat %>;
76 var maxlon = <%= bbox.max_lon %>;
77 var maxlat = <%= bbox.max_lat %>;
78 var bbox = new OpenLayers.Bounds(minlon, minlat, maxlon, maxlat);
79 var centre = bbox.getCenterLonLat();
81 map.zoomToExtent(proj(bbox));
85 $("#browse_map .geolink").show();
87 $("#remote_area_edit").click(function (event) {
88 return remoteEditHandler(event, bbox);
91 <% if preferred_editor == "remote" -%>
92 $("#area_edit").click(function (event) {
93 return remoteEditHandler(event, bbox);
97 updatelinks(centre.lon, centre.lat, 16, null, minlon, minlat, maxlon, maxlat)
98 <% elsif map.instance_of? Note %>
99 var centre = new OpenLayers.LonLat(<%= map.lon %>, <%= map.lat %>);
101 setMapCenter(centre, 16);
102 addMarkerToMap(centre);
104 var bbox = getMapExtent();
106 $("#loading").hide();
107 $("#browse_map .geolink").show();
109 $("#remote_area_edit").click(function (event) {
110 return remoteEditHandler(event, bbox);
113 <% if preferred_editor == "remote" -%>
114 $("#area_edit").click(function (event) {
115 return remoteEditHandler(event, bbox);
119 updatelinks(centre.lon, centre.lat, 16, null, bbox.left, bbox.bottom, bbox.right, bbox.top)
121 var obj_type = "<%= map.class.name.downcase %>";
122 var obj_id = <%= map.id %>;
123 var obj_version = <%= map.version %>;
124 var obj_visible = <%= map.visible %>;
125 var url = "/api/<%= API_VERSION %>/<%= map.class.name.downcase %>/<%= map.id %>";
127 if (obj_type != "node") {
129 } else if (!obj_visible) {
130 var previous_version = obj_version - 1;
131 url += "/" + previous_version;
134 $("#object_larger_map").hide();
135 $("#object_edit").hide();
137 addObjectToMap(url, true, function(extent) {
138 $("#loading").hide();
139 $("#browse_map .geolink").show();
142 extent.transform(map.getProjectionObject(), map.displayProjection);
144 var centre = extent.getCenterLonLat();
146 $("#remote_area_edit").click(function (event) {
147 return remoteEditHandler(event, extent);
150 <% if preferred_editor == "remote" -%>
151 $("#area_edit").click(function (event) {
152 return remoteEditHandler(event, extent);
156 $("#remote_object_edit").click(function (event) {
157 return remoteEditHandler(event, extent, "<%= map.class.to_s.downcase + map.id.to_s %>");
160 <% if preferred_editor == "remote" -%>
161 $("#object_edit").click(function (event) {
162 return remoteEditHandler(event, extent, "<%= map.class.to_s.downcase + map.id.to_s %>");
166 $("#object_larger_map").show();
167 $("#object_edit").show();
169 updatelinks(centre.lon, centre.lat, 16, null, extent.left, extent.bottom, extent.right, extent.top, "<%= map.class.to_s.downcase %>", <%= map.id %>);
171 $("#small_map").hide();
176 createMenu("area_edit", "area_edit_menu", "right");
177 createMenu("object_edit", "object_edit_menu", "right");
180 window.onload = init;