-<%= javascript_include_tag '/openlayers/OpenLayers.js' %>
-<%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
-<%= javascript_include_tag 'map.js' %>
-<td align="right">
- <% if map.instance_of? Changeset or map.visible %>
- <div id="small_map" style="width:250px; height: 300px; border: solid 1px black">
- </div>
- <span id="loading"><%= t 'browse.map.loading' %></span>
- <a id="larger_map" href=""></a>
- <br />
- <a id="main_map" href=""></a>
- <% else %>
- <%= t 'browse.map.deleted' %>
- <% end %>
-</td>
-<% if map.instance_of? Changeset or map.visible %>
- <script type="text/javascript">
- OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
-
- function init() {
- var map = createMap("small_map", {
- controls: [ new OpenLayers.Control.Navigation() ]
- });
-
- <% if map.instance_of? Changeset %>
- var minlon = <%= map.min_lon / GeoRecord::SCALE.to_f %>;
- var minlat = <%= map.min_lat / GeoRecord::SCALE.to_f %>;
- var maxlon = <%= map.max_lon / GeoRecord::SCALE.to_f %>;
- var maxlat = <%= map.max_lat / GeoRecord::SCALE.to_f %>;
- var bbox = new OpenLayers.Bounds(minlon, minlat, maxlon, maxlat);
-
- setMapExtent(bbox);
- addBoxToMap(bbox);
-
- $("loading").innerHTML = "";
-
- $("larger_map").href = '<%= url_for :controller => 'browse', :action => (map.class.to_s.downcase + '_map'), :id => map.id, :only_path => true %>';
- $("larger_map").innerHTML = "<%= t 'browse.map.view_larger_map' %>";
-
- $("main_map").href = '/?minlon='+minlon+'&minlat='+minlat+'&maxlon='+maxlon+'&maxlat='+maxlat+'&box=yes';
- $("main_map").innerHTML = "<%= t 'browse.map.view_main_map' %>";
- <% else %>
- var obj_type = "<%= map.class.name.downcase %>";
- var obj_id = <%= map.id %>;
- var url = "/api/<%= "#{API_VERSION}" %>/<%= map.class.name.downcase %>/<%= map.id %>";
-
- if (obj_type != "node") {
- url += "/full";
- }
-
- var osm_layer = new OpenLayers.Layer.GML("OSM", url, {
- format: OpenLayers.Format.OSM,
- projection: new OpenLayers.Projection("EPSG:4326")
- });
-
- osm_layer.events.register("loadend", osm_layer, function() {
- $("loading").innerHTML = "";
+<div id="browse_map" class='clearfix content_map'>
+ <% if map.instance_of? Changeset or (map.instance_of? Node and map.version > 1) or map.visible? %>
- if (this.features.length) {
- var extent = this.features[0].geometry.getBounds();
-
- for (var i = 1; i < this.features.length; i++) {
- extent.extend(this.features[i].geometry.getBounds());
- }
-
- if (extent) {
- this.map.zoomToExtent(extent);
- } else {
- this.map.zoomToMaxExtent();
- }
-
- var center = getMapCenter();
-
- $("larger_map").href = '<%= url_for :controller => 'browse', :action => (map.class.to_s.downcase + '_map'), :id => map.id, :only_path => true %>';
- $("larger_map").innerHTML = "<%= t 'browse.map.view_larger_map' %>";
-
- $("main_map").href = '/?lat='+center.lat+'&lon='+center.lon+'&zoom='+this.map.getZoom();
- $("main_map").innerHTML = "<%= t 'browse.map.view_main_map' %>";
- } else {
- $("small_map").style.display = "none";
- }
- });
-
- map.addLayer(osm_layer);
+ <% content_for :head do %>
+ <%= javascript_include_tag "browse" %>
+ <% end %>
- osm_layer.loadGML();
- osm_layer.loaded = true;
- <% end %>
- }
+ <%
+ if map.instance_of? Changeset
+ bbox = map.bbox.to_unscaled
+ data = {
+ :type => "changeset",
+ :id => map.id,
+ :minlon => bbox.min_lon,
+ :minlat => bbox.min_lat,
+ :maxlon => bbox.max_lon,
+ :maxlat => bbox.max_lat
+ }
+ elsif map.instance_of? Note
+ data = {
+ :type => "note",
+ :id => map.id,
+ :lon => map.lon,
+ :lat => map.lat
+ }
+ else
+ data = {
+ :type => map.class.name.downcase,
+ :id => map.id,
+ :version => map.version,
+ :visible => map.visible
+ }
+ end
+ %>
+ <%= content_tag "div", "", :id => "small_map", :data => data %>
+ <span id="loading"><%= t 'browse.map.loading' %></span>
+
+ <ul class='secondary-actions clearfix'>
+ <li>
+ <% if map.instance_of? Note -%>
+ <%= link_to t("browse.map.larger.area"),
+ root_path(:notes => "yes"),
+ :id => "area_larger_map",
+ :class => "geolink bbox" %>
+ <% else -%>
+ <%= link_to t("browse.map.larger.area"),
+ root_path(:box => "yes"),
+ :id => "area_larger_map",
+ :class => "geolink bbox" %>
+ <% end -%>
+ </li>
+ <li>
+ <%= render :partial => 'layouts/edit_menu',
+ :locals => { :link_text => t("browse.map.edit.area"),
+ :link_class => 'bbox' } %>
+ </li>
+ </ul>
+
+ <% unless map.instance_of? Changeset %>
+ <ul class='secondary-actions clearfix'>
+ <li>
+ <%= link_to t("browse.map.larger." + map.class.to_s.downcase),
+ root_path,
+ :id => "object_larger_map",
+ :class => "geolink object" %>
+ </li>
+ <li>
+ <%= render :partial => 'layouts/edit_menu',
+ :locals => { :link_text => t("browse.map.edit." + map.class.to_s.downcase),
+ :link_class => 'object' } %>
+ </li>
+ </ul>
+ <% end %>
- window.onload = init;
- </script>
-<% end %>
+ <% else %>
+ <%= t 'browse.map.deleted' %>
+ <% end %>
+</div>