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 <% if map.instance_of? Note -%>
13 <%= link_to(t("browse.map.larger.area"), { :controller => :site, :action => :index, :notes => "yes" }, { :id => "area_larger_map", :class => "geolink bbox" }) %>
15 <%= link_to(t("browse.map.larger.area"), { :controller => :site, :action => :index, :box => "yes" }, { :id => "area_larger_map", :class => "geolink bbox" }) %>
18 <%= link_to(h(t("browse.map.edit.area")) + content_tag(:span, "▾", :class => "menuicon"), { :controller => :site, :action => :edit }, { :id => "area_edit", :class => "geolink bbox" }) %>
19 <% unless map.instance_of? Changeset or map.instance_of? Note %>
21 <%= link_to(t("browse.map.larger." + map.class.to_s.downcase), { :controller => :site, :action => :index }, { :id => "object_larger_map", :class => "geolink object" }) %>
23 <%= 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" }) %>
26 <%= t 'browse.map.deleted' %>
30 <div id="area_edit_menu" class="menu">
32 <% Editors::ALL_EDITORS.each do |editor| %>
33 <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>
38 <div id="object_edit_menu" class="menu">
40 <% Editors::ALL_EDITORS.each do |editor| %>
41 <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>
46 <% if map.instance_of? Changeset or (map.instance_of? Node and map.version > 1) or map.visible? %>
47 <script type="text/javascript">
48 OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
50 function remoteEditHandler(event, bbox, select) {
51 var left = bbox.left - 0.0001;
52 var top = bbox.top + 0.0001;
53 var right = bbox.right + 0.0001;
54 var bottom = bbox.bottom - 0.0001;
57 $("#linkloader").load(function () { loaded = true; });
60 $("#linkloader").attr("src", "http://127.0.0.1:8111/load_and_zoom?left=" + left + "&top=" + top + "&right=" + right + "&bottom=" + bottom + "&select=" + select);
62 $("#linkloader").attr("src", "http://127.0.0.1:8111/load_and_zoom?left=" + left + "&top=" + top + "&right=" + right + "&bottom=" + bottom);
65 setTimeout(function () {
66 if (!loaded) alert("<%=j t('site.index.remote_failed') %>");
73 var map = createMap("small_map", {
74 controls: [ new OpenLayers.Control.Navigation() ]
77 <% if map.instance_of? Changeset -%>
78 <% bbox = map.bbox.to_unscaled %>
79 var minlon = <%= bbox.min_lon %>;
80 var minlat = <%= bbox.min_lat %>;
81 var maxlon = <%= bbox.max_lon %>;
82 var maxlat = <%= bbox.max_lat %>;
83 var bbox = new OpenLayers.Bounds(minlon, minlat, maxlon, maxlat);
84 var centre = bbox.getCenterLonLat();
86 map.zoomToExtent(proj(bbox));
90 $("#browse_map .geolink").show();
92 $("#remote_area_edit").click(function (event) {
93 return remoteEditHandler(event, bbox);
96 <% if preferred_editor == "remote" -%>
97 $("#area_edit").click(function (event) {
98 return remoteEditHandler(event, bbox);
102 updatelinks(centre.lon, centre.lat, 16, null, minlon, minlat, maxlon, maxlat)
103 <% elsif map.instance_of? Note %>
104 var centre = new OpenLayers.LonLat(<%= map.lon %>, <%= map.lat %>);
106 setMapCenter(centre, 16);
107 addMarkerToMap(centre);
109 var bbox = getMapExtent();
111 $("#loading").hide();
112 $("#browse_map .geolink").show();
114 $("#remote_area_edit").click(function (event) {
115 return remoteEditHandler(event, bbox);
118 <% if preferred_editor == "remote" -%>
119 $("#area_edit").click(function (event) {
120 return remoteEditHandler(event, bbox);
124 updatelinks(centre.lon, centre.lat, 16, null, bbox.left, bbox.bottom, bbox.right, bbox.top)
126 var obj_type = "<%= map.class.name.downcase %>";
127 var obj_id = <%= map.id %>;
128 var obj_version = <%= map.version %>;
129 var obj_visible = <%= map.visible %>;
130 var url = "/api/<%= API_VERSION %>/<%= map.class.name.downcase %>/<%= map.id %>";
132 if (obj_type != "node") {
134 } else if (!obj_visible) {
135 var previous_version = obj_version - 1;
136 url += "/" + previous_version;
139 $("#object_larger_map").hide();
140 $("#object_edit").hide();
142 addObjectToMap(url, true, function(extent) {
143 $("#loading").hide();
144 $("#browse_map .geolink").show();
147 extent.transform(map.getProjectionObject(), map.displayProjection);
149 var centre = extent.getCenterLonLat();
151 $("#remote_area_edit").click(function (event) {
152 return remoteEditHandler(event, extent);
155 <% if preferred_editor == "remote" -%>
156 $("#area_edit").click(function (event) {
157 return remoteEditHandler(event, extent);
161 $("#remote_object_edit").click(function (event) {
162 return remoteEditHandler(event, extent, "<%= map.class.to_s.downcase + map.id.to_s %>");
165 <% if preferred_editor == "remote" -%>
166 $("#object_edit").click(function (event) {
167 return remoteEditHandler(event, extent, "<%= map.class.to_s.downcase + map.id.to_s %>");
171 $("#object_larger_map").show();
172 $("#object_edit").show();
174 updatelinks(centre.lon, centre.lat, 16, null, extent.left, extent.bottom, extent.right, extent.top, "<%= map.class.to_s.downcase %>", <%= map.id %>);
176 $("#small_map").hide();
181 createMenu("area_edit", "area_edit_menu", "right");
182 createMenu("object_edit", "object_edit_menu", "right");
185 window.onload = init;