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) {
50 $("linkloader").observe("load", function () { loaded = true; });
53 $("linkloader").src = "http://127.0.0.1:8111/load_and_zoom?left=" + bbox.left + "&top=" + bbox.top + "&right=" + bbox.right + "&bottom=" + bbox.bottom + "&select=" + select;
55 $("linkloader").src = "http://127.0.0.1:8111/load_and_zoom?left=" + bbox.left + "&top=" + bbox.top + "&right=" + bbox.right + "&bottom=" + bbox.bottom;
58 setTimeout(function () {
59 if (!loaded) alert("<%= escape_javascript(t('site.index.remote_failed')) %>");
66 var map = createMap("small_map", {
67 controls: [ new OpenLayers.Control.Navigation() ]
70 <% if map.instance_of? Changeset %>
71 var minlon = <%= map.min_lon / GeoRecord::SCALE.to_f %>;
72 var minlat = <%= map.min_lat / GeoRecord::SCALE.to_f %>;
73 var maxlon = <%= map.max_lon / GeoRecord::SCALE.to_f %>;
74 var maxlat = <%= map.max_lat / GeoRecord::SCALE.to_f %>;
75 var bbox = new OpenLayers.Bounds(minlon, minlat, maxlon, maxlat);
76 var centre = bbox.getCenterLonLat();
81 $("loading").style.display = "none";
83 $$("#browse_map .geolink").each(function (link) {
84 link.style.display = "inline";
87 $("remote_area_edit").observe("click", function (event) {
88 remoteEditHandler(event, extent);
91 <% if preferred_editor == "remote" %>
92 $("area_edit").observe("click", function (event) {
93 remoteEditHandler(event, extent);
97 updatelinks(centre.lon, centre.lat, 16, null, minlon, minlat, maxlon, maxlat)
99 var obj_type = "<%= map.class.name.downcase %>";
100 var obj_id = <%= map.id %>;
101 var obj_version = <%= map.version %>;
102 var obj_visible = <%= map.visible %>;
103 var url = "/api/<%= "#{API_VERSION}" %>/<%= map.class.name.downcase %>/<%= map.id %>";
105 if (obj_type != "node") {
107 } else if (!obj_visible) {
108 var previous_version = obj_version - 1;
109 url += "/" + previous_version;
112 addObjectToMap(url, true, function(extent) {
113 $("loading").style.display = "none";
115 $$("#browse_map .geolink").each(function (link) {
116 link.style.display = "inline";
120 extent.transform(map.getProjectionObject(), map.displayProjection);
122 var centre = extent.getCenterLonLat();
124 $("remote_area_edit").observe("click", function (event) {
125 remoteEditHandler(event, extent);
128 <% if preferred_editor == "remote" %>
129 $("area_edit").observe("click", function (event) {
130 remoteEditHandler(event, extent);
134 <% unless map.instance_of? Changeset %>
135 $("remote_object_edit").observe("click", function (event) {
136 remoteEditHandler(event, extent, "<%= map.class.to_s.downcase + map.id.to_s %>");
139 $("object_larger_map").innerHTML = "<%= t('browse.map.larger.' + map.class.to_s.downcase) %>";
140 $("object_edit").innerHTML = "<%= t('browse.map.edit.' + map.class.to_s.downcase) %>";
143 updatelinks(centre.lon, centre.lat, 16, null, extent.left, extent.bottom, extent.right, extent.top, "<%= map.class.to_s.downcase %>", <%= map.id %>)
145 $("small_map").style.display = "none";
150 createMenu("area_edit", "area_edit_menu", 1000, "right");
151 createMenu("object_edit", "object_edit_menu", 1000, "right");
154 window.onload = init;