X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/8bc8e537b273e8e260a12f598d77dc4135f9d32c..336d40f2c593cc2af6d669e30d17ec9e4c6f0734:/app/views/browse/_map.html.erb diff --git a/app/views/browse/_map.html.erb b/app/views/browse/_map.html.erb index 9a150ae05..f84a2ec9f 100644 --- a/app/views/browse/_map.html.erb +++ b/app/views/browse/_map.html.erb @@ -6,9 +6,11 @@
<%= t 'browse.map.loading' %> - -
- + + <% unless map.instance_of? Changeset %> +
+ + <% end %> <% else %> <%= t 'browse.map.deleted' %> <% end %> @@ -34,11 +36,8 @@ $("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' %>"; + $("area_larger_map").href = '/?minlon='+minlon+'&minlat='+minlat+'&maxlon='+maxlon+'&maxlat='+maxlat+'&box=yes'; + $("area_larger_map").innerHTML = "<%= t 'browse.map.larger.area' %>"; <% else %> var obj_type = "<%= map.class.name.downcase %>"; var obj_id = <%= map.id %>; @@ -48,43 +47,23 @@ 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() { + addObjectToMap(url, true, function(extent) { $("loading").innerHTML = ""; - 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) { + extent.transform(map.getProjectionObject(), map.displayProjection); - if (extent) { - this.map.zoomToExtent(extent); - } else { - this.map.zoomToMaxExtent(); - } + $("area_larger_map").href = '/?minlon='+extent.left+'&minlat='+extent.bottom+'&maxlon='+extent.right+'&maxlat='+extent.top; + $("area_larger_map").innerHTML = "<%= t 'browse.map.larger.area' %>"; - 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' %>"; + <% unless map.instance_of? Changeset %> + $("object_larger_map").href = '/?<%= map.class.to_s.downcase %>=<%= map.id %>'; + $("object_larger_map").innerHTML = "<%= t('browse.map.larger.' + map.class.to_s.downcase) %>"; + <% end %> } else { $("small_map").style.display = "none"; } }); - - map.addLayer(osm_layer); - - osm_layer.loadGML(); - osm_layer.loaded = true; <% end %> }