1 <div id="changeset_list_map">
4 <script type="text/javascript">
7 function highlightChangeset(id) {
8 var feature = vectors.getFeatureByFid(id);
9 var bounds = feature.geometry.getBounds();
11 if (bounds.containsBounds(map.getExtent())) {
12 bounds = map.getExtent().scale(1.1);
15 if (highlight) vectors.removeFeatures(highlight);
17 highlight = new OpenLayers.Feature.Vector(bounds.toGeometry(), {}, {
19 strokeColor: "#ee9900",
24 vectors.addFeatures(highlight);
26 $("#tr-changeset-" + id).addClass("selected");
29 function unHighlightChangeset(id) {
30 vectors.removeFeatures(highlight);
32 $("#tr-changeset-" + id).removeClass("selected");
35 $(document).ready(function () {
36 var map = createMap("changeset_list_map", {
38 new OpenLayers.Control.Navigation(),
39 new OpenLayers.Control.Zoom(),
40 new OpenLayers.Control.SimplePanZoom()
44 var bounds = new OpenLayers.Bounds();
46 <% @edits.each do |edit| %>
47 <% if edit.has_valid_bbox? %>
48 <% bbox = edit.bbox.to_unscaled %>
49 var minlon = <%= bbox.min_lon %>;
50 var minlat = <%= bbox.min_lat %>;
51 var maxlon = <%= bbox.max_lon %>;
52 var maxlat = <%= bbox.max_lat %>;
53 var bbox = new OpenLayers.Bounds(minlon, minlat, maxlon, maxlat);
57 addBoxToMap(bbox, "<%= edit.id %>", true);
62 "featureselected": function(feature) {
63 highlightChangeset(feature.feature.fid);
65 "featureunselected": function(feature) {
66 unHighlightChangeset(feature.feature.fid);
70 var selectControl = new OpenLayers.Control.SelectFeature(vectors, {
74 map.addControl(selectControl);
75 selectControl.activate();
78 map.zoomToExtent(proj(new OpenLayers.Bounds(<%= @bbox %>)));
80 map.zoomToExtent(proj(bounds));