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 var minlon = <%= map.min_lon / GeoRecord::SCALE.to_f %>;
76 var minlat = <%= map.min_lat / GeoRecord::SCALE.to_f %>;
77 var maxlon = <%= map.max_lon / GeoRecord::SCALE.to_f %>;
78 var maxlat = <%= map.max_lat / GeoRecord::SCALE.to_f %>;
79 var bbox = new OpenLayers.Bounds(minlon, minlat, maxlon, maxlat);
80 var centre = bbox.getCenterLonLat();
85 $("loading").style.display = "none";
87 $$("#browse_map .geolink").each(function (link) {
88 link.style.display = "inline";
91 $("remote_area_edit").observe("click", function (event) {
92 remoteEditHandler(event, bbox);
95 <% if preferred_editor == "remote" %>
96 $("area_edit").observe("click", function (event) {
97 remoteEditHandler(event, bbox);
101 updatelinks(centre.lon, centre.lat, 16, null, minlon, minlat, maxlon, maxlat)
103 var obj_type = "<%= map.class.name.downcase %>";
104 var obj_id = <%= map.id %>;
105 var obj_version = <%= map.version %>;
106 var obj_visible = <%= map.visible %>;
107 var url = "/api/<%= "#{API_VERSION}" %>/<%= map.class.name.downcase %>/<%= map.id %>";
109 if (obj_type != "node") {
111 } else if (!obj_visible) {
112 var previous_version = obj_version - 1;
113 url += "/" + previous_version;
116 addObjectToMap(url, true, function(extent) {
117 $("loading").style.display = "none";
119 $$("#browse_map .geolink").each(function (link) {
120 link.style.display = "inline";
124 extent.transform(map.getProjectionObject(), map.displayProjection);
126 var centre = extent.getCenterLonLat();
128 $("remote_area_edit").observe("click", function (event) {
129 remoteEditHandler(event, extent);
132 <% if preferred_editor == "remote" %>
133 $("area_edit").observe("click", function (event) {
134 remoteEditHandler(event, extent);
138 <% unless map.instance_of? Changeset %>
139 $("remote_object_edit").observe("click", function (event) {
140 remoteEditHandler(event, extent, "<%= map.class.to_s.downcase + map.id.to_s %>");
143 $("object_larger_map").innerHTML = "<%= t('browse.map.larger.' + map.class.to_s.downcase) %>";
144 $("object_edit").innerHTML = "<%= 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").style.display = "none";
154 createMenu("area_edit", "area_edit_menu", 1000, "right");
155 createMenu("object_edit", "object_edit_menu", 1000, "right");
158 window.onload = init;