1 <%= javascript_include_tag 'openlayers.js' %>
2 <%= javascript_include_tag 'map.js' %>
4 <div id="changeset_list_map">
7 <script type="text/javascript">
10 function highlightChangeset(id) {
11 var feature = vectors.getFeatureByFid(id);
12 var bounds = feature.geometry.getBounds();
14 if (bounds.containsBounds(map.getExtent())) {
15 bounds = map.getExtent().scale(1.1);
18 if (highlight) vectors.removeFeatures(highlight);
20 highlight = new OpenLayers.Feature.Vector(bounds.toGeometry(), {}, {
22 strokeColor: "#ee9900",
27 vectors.addFeatures(highlight);
29 $("#tr-changeset-" + id).addClass("selected");
32 function unHighlightChangeset(id) {
33 vectors.removeFeatures(highlight);
35 $("#tr-changeset-" + id).removeClass("selected");
38 $(document).ready(function () {
39 var map = createMap("changeset_list_map", {
41 new OpenLayers.Control.Navigation(),
42 new OpenLayers.Control.Zoom(),
43 new OpenLayers.Control.SimplePanZoom()
47 var bounds = new OpenLayers.Bounds();
49 <% @edits.each do |edit| %>
50 <% if edit.has_valid_bbox? %>
51 <% bbox = edit.bbox.to_unscaled %>
52 var minlon = <%= bbox.min_lon %>;
53 var minlat = <%= bbox.min_lat %>;
54 var maxlon = <%= bbox.max_lon %>;
55 var maxlat = <%= bbox.max_lat %>;
56 var bbox = new OpenLayers.Bounds(minlon, minlat, maxlon, maxlat);
60 addBoxToMap(bbox, "<%= edit.id %>", true);
65 "featureselected": function(feature) {
66 highlightChangeset(feature.feature.fid);
68 "featureunselected": function(feature) {
69 unHighlightChangeset(feature.feature.fid);
73 var selectControl = new OpenLayers.Control.SelectFeature(vectors, {
77 map.addControl(selectControl);
78 selectControl.activate();
81 map.zoomToExtent(proj(new OpenLayers.Bounds(<%= @bbox %>)));
83 map.zoomToExtent(proj(bounds));