var bounds = new OpenLayers.Bounds();
- <% @edits.each do |edit| %>
- <% if edit.has_valid_bbox? %>
- <% bbox = edit.bbox.to_unscaled %>
- var minlon = <%= bbox.min_lon %>;
- var minlat = <%= bbox.min_lat %>;
- var maxlon = <%= bbox.max_lon %>;
- var maxlat = <%= bbox.max_lat %>;
- var bbox = new OpenLayers.Bounds(minlon, minlat, maxlon, maxlat);
+ $("[data-changeset]").each(function () {
+ var changeset = $(this).data('changeset');
+ if (changeset.bbox) {
+ var bbox = new OpenLayers.Bounds(changeset.bbox.minlon, changeset.bbox.minlat, changeset.bbox.maxlon, changeset.bbox.maxlat);
- bounds.extend(bbox);
+ bounds.extend(bbox);
- addBoxToMap(bbox, "<%= edit.id %>", true);
- <% end %>
- <% end %>
+ addBoxToMap(bbox, changeset.id, true);
+ }
+ });
vectors.events.on({
"featureselected": function(feature) {
map.addControl(selectControl);
selectControl.activate();
- <% if ! @bbox.nil? %>
- map.zoomToExtent(proj(new OpenLayers.Bounds(<%= @bbox %>)));
- <% else %>
+ var params = OSM.mapParams();
+ if (params.bbox) {
+ map.zoomToExtent(proj(new OpenLayers.Bounds(params.minlon, params.minlat, params.maxlon, params.maxlat)));
+ } else {
map.zoomToExtent(proj(bounds));
- <% end %>
+ }
});
</script>