1 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
2 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
3 <%= javascript_include_tag 'map.js' %>
5 <iframe id="linkloader" style="display: none">
9 <% if map.instance_of? Changeset or (map.instance_of? Node and map.version > 1) or map.visible %>
12 <span id="loading"><%= t 'browse.map.loading' %></span>
13 <%= link_to(t("browse.map.larger.area"), { :controller => :site, :action => :index, :box => "yes" }, { :id => "area_larger_map", :class => "geolink bbox" }) %>
15 <%= link_to(t("browse.map.edit.area"), { :controller => :site, :action => :edit }, { :id => "area_edit", :class => "geolink bbox" }) %>
16 <% unless map.instance_of? Changeset %>
18 <%= link_to("", { :controller => :site, :action => :index }, { :id => "object_larger_map", :class => "geolink object" }) %>
20 <%= link_to("", { :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 OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
47 function remoteEditHandler(event, bbox, select) {
48 var left = bbox.left - 0.0001;
49 var top = bbox.top + 0.0001;
50 var right = bbox.right + 0.0001;
51 var bottom = bbox.bottom - 0.0001;
54 $("linkloader").observe("load", function () { loaded = true; });
57 $("linkloader").src = "http://127.0.0.1:8111/load_and_zoom?left=" + left + "&top=" + top + "&right=" + right + "&bottom=" + bottom + "&select=" + select;
59 $("linkloader").src = "http://127.0.0.1:8111/load_and_zoom?left=" + left + "&top=" + top + "&right=" + right + "&bottom=" + bottom;
62 setTimeout(function () {
63 if (!loaded) alert("<%= escape_javascript(t('site.index.remote_failed')) %>");
70 var map = createMap("small_map", {
71 controls: [ new OpenLayers.Control.Navigation() ]
74 <% if map.instance_of? Changeset %>
75 <% bbox = map.bbox.to_unscaled %>
76 var minlon = <%= bbox.min_lon %>;
77 var minlat = <%= bbox.min_lat %>;
78 var maxlon = <%= bbox.max_lon %>;
79 var maxlat = <%= bbox.max_lat %>;
80 var bbox = new OpenLayers.Bounds(minlon, minlat, maxlon, maxlat);
81 var centre = bbox.getCenterLonLat();
86 $("loading").style.display = "none";
88 $$("#browse_map .geolink").each(function (link) {
89 link.style.display = "inline";
92 $("remote_area_edit").observe("click", function (event) {
93 remoteEditHandler(event, bbox);
96 <% if preferred_editor == "remote" %>
97 $("area_edit").observe("click", function (event) {
98 remoteEditHandler(event, bbox);
102 updatelinks(centre.lon, centre.lat, 16, null, minlon, minlat, maxlon, maxlat)
104 var obj_type = "<%= map.class.name.downcase %>";
105 var obj_id = <%= map.id %>;
106 var obj_version = <%= map.version %>;
107 var obj_visible = <%= map.visible %>;
108 var url = "/api/<%= "#{API_VERSION}" %>/<%= map.class.name.downcase %>/<%= map.id %>";
110 if (obj_type != "node") {
112 } else if (!obj_visible) {
113 var previous_version = obj_version - 1;
114 url += "/" + previous_version;
117 addObjectToMap(url, true, function(extent) {
118 $("loading").style.display = "none";
120 $$("#browse_map .geolink").each(function (link) {
121 link.style.display = "inline";
125 extent.transform(map.getProjectionObject(), map.displayProjection);
127 var centre = extent.getCenterLonLat();
129 $("remote_area_edit").observe("click", function (event) {
130 remoteEditHandler(event, extent);
133 <% if preferred_editor == "remote" %>
134 $("area_edit").observe("click", function (event) {
135 remoteEditHandler(event, extent);
139 <% unless map.instance_of? Changeset %>
140 $("remote_object_edit").observe("click", function (event) {
141 remoteEditHandler(event, extent, "<%= map.class.to_s.downcase + map.id.to_s %>");
144 $("object_larger_map").innerHTML = "<%= t('browse.map.larger.' + map.class.to_s.downcase) %>";
145 $("object_edit").innerHTML = "<%= t('browse.map.edit.' + map.class.to_s.downcase) %>";
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").style.display = "none";
155 createMenu("area_edit", "area_edit_menu", 1000, "right");
156 createMenu("object_edit", "object_edit_menu", 1000, "right");
159 window.onload = init;