- <% if bbox %>
- var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
-
- setMapExtent(bbox);
- <% if box %>
- // IE requires Vector layers be initialised on page load, and not under deferred script conditions
- Event.observe(window, 'load', function() {addBoxToMap(bbox)});
- <% end %>
- <% elsif object %>
- // Display node/way/relation on the map
- obj_type = "<%= object_type %>";
- obj_id = <%= object_id %>;
- var url = "/api/<%= "#{API_VERSION}" %>/<%= object_type %>/<%= object_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() {
- 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());
- }
-
- <% unless lat_lon_zoom_via_params %>
- if (extent) {
- this.map.zoomToExtent(extent);
- } else {
- this.map.zoomToMaxExtent();
- }
- <% else %>
- var center = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
- var zoom = <%= zoom %>;
- <% end %>
-
- var center = getMapCenter();
- }
- });
-
- map.addLayer(osm_layer);
- osm_layer.loadGML();
- osm_layer.loaded = true;
-
- <% else %>
- var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
- var zoom = <%= zoom %>;
-
- <% if params['scale'] and params['scale'].length > 0 then %>
- zoom = scaleToZoom(<%= params['scale'].to_f() %>);
- <% end %>
-
- setMapCenter(centre, zoom);
+ <% unless object_zoom %>
+ <% if bbox %>
+ var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
+
+ map.zoomToExtent(proj(bbox));
+
+ <% if box %>
+ $(window).load(function() { addBoxToMap(bbox) });
+ <% end %>
+ <% else %>
+ var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
+ <% if params[:scale].to_f > 0 then -%>
+ var zoom = <%= scale_to_zoom params[:scale] %>;
+ <% else -%>
+ var zoom = <%= zoom %>;
+ <% end -%>
+
+ setMapCenter(centre, zoom);
+ <% end %>