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(t("browse.map.edit.area"), { :controller => :site, :action => :edit }, { :id => "area_edit", :class => "geolink bbox" }) %>
15 <% unless map.instance_of? Changeset %>
17 <%= link_to("", { :controller => :site, :action => :index }, { :id => "object_larger_map", :class => "geolink object" }) %>
19 <%= link_to("", { :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 addObjectToMap(url, true, function(extent) {
114 $("#loading").hide();
115 $("#browse_map .geolink").show();
118 extent.transform(map.getProjectionObject(), map.displayProjection);
120 var centre = extent.getCenterLonLat();
122 $("#remote_area_edit").click(function (event) {
123 return remoteEditHandler(event, extent);
126 <% if preferred_editor == "remote" -%>
127 $("#area_edit").click(function (event) {
128 return remoteEditHandler(event, extent);
132 <% unless map.instance_of? Changeset -%>
133 $("#remote_object_edit").click(function (event) {
134 return remoteEditHandler(event, extent, "<%= map.class.to_s.downcase + map.id.to_s %>");
137 <% if preferred_editor == "remote" -%>
138 $("#object_edit").click(function (event) {
139 return remoteEditHandler(event, extent, "<%= map.class.to_s.downcase + map.id.to_s %>");
143 $("#object_larger_map").html("<%=j t('browse.map.larger.' + map.class.to_s.downcase) %>");
144 $("#object_edit").html("<%=j t('browse.map.edit.' + map.class.to_s.downcase) %>");
147 updatelinks(centre.lon, centre.lat, 16, null, extent.left, extent.bottom, extent.right, extent.top, "<%= map.class.to_s.downcase %>", <%= map.id %>);
149 $("#small_map").hide();
154 createMenu("area_edit", "area_edit_menu", 1000, "right");
155 createMenu("object_edit", "object_edit_menu", 1000, "right");
158 window.onload = init;