1 <%= javascript_include_tag 'map.js' %>
3 <div id="changeset_list_map">
6 <script type="text/javascript">
9 function highlightChangeset(id) {
10 var feature = vectors.getFeatureByFid(id);
11 var bounds = feature.geometry.getBounds();
13 if (bounds.containsBounds(map.getExtent())) {
14 bounds = map.getExtent().scale(1.1);
17 if (highlight) vectors.removeFeatures(highlight);
19 highlight = new OpenLayers.Feature.Vector(bounds.toGeometry(), {}, {
21 strokeColor: "#ee9900",
26 vectors.addFeatures(highlight);
28 $("#tr-changeset-" + id).addClass("selected");
31 function unHighlightChangeset(id) {
32 vectors.removeFeatures(highlight);
34 $("#tr-changeset-" + id).removeClass("selected");
37 $(document).ready(function () {
38 var map = createMap("changeset_list_map", {
40 new OpenLayers.Control.Navigation(),
41 new OpenLayers.Control.Zoom(),
42 new OpenLayers.Control.SimplePanZoom()
46 var bounds = new OpenLayers.Bounds();
48 <% @edits.each do |edit| %>
49 <% if edit.has_valid_bbox? %>
50 <% bbox = edit.bbox.to_unscaled %>
51 var minlon = <%= bbox.min_lon %>;
52 var minlat = <%= bbox.min_lat %>;
53 var maxlon = <%= bbox.max_lon %>;
54 var maxlat = <%= bbox.max_lat %>;
55 var bbox = new OpenLayers.Bounds(minlon, minlat, maxlon, maxlat);
59 addBoxToMap(bbox, "<%= edit.id %>", true);
64 "featureselected": function(feature) {
65 highlightChangeset(feature.feature.fid);
67 "featureunselected": function(feature) {
68 unHighlightChangeset(feature.feature.fid);
72 var selectControl = new OpenLayers.Control.SelectFeature(vectors, {
76 map.addControl(selectControl);
77 selectControl.activate();
80 map.zoomToExtent(proj(new OpenLayers.Bounds(<%= @bbox %>)));
82 map.zoomToExtent(proj(bounds));