X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/be68d7319ee92548478c34740f5d00aa3a58d0d9..0030c7753740820fab12455dd841cd39c58b6475:/app/views/site/index.html.erb
diff --git a/app/views/site/index.html.erb b/app/views/site/index.html.erb
index b4719f671..f4a2abd09 100644
--- a/app/views/site/index.html.erb
+++ b/app/views/site/index.html.erb
@@ -20,7 +20,7 @@
@@ -123,7 +123,6 @@ end
<%= javascript_include_tag '/openlayers/OpenLayers.js' %>
<%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
-<%= javascript_include_tag 'openstreetbugs.js' %>
<%= javascript_include_tag 'map.js' %>
<%= render :partial => 'resize' %>
@@ -146,24 +145,64 @@ end
map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData);
map.addLayer(map.dataLayer);
- map.osbLayer = new OpenLayers.Layer.OpenStreetBugs("Notes", {
- serverURL: "/api/0.6/",
- iconOpen: new OpenLayers.Icon("<%= image_path "open_note_marker.png" %>", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)),
- iconClosed: new OpenLayers.Icon("<%= image_path "closed_noe_marker.png" %>", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)),
- readonly: false,
- setCookie: false,
- permalinkURL: "http://www.openstreetmap.org/",
- theme: "<%= stylesheet_path "openstreetbugs" %>",
- visibility: <%= params[:notes] == "yes" %>
+ map.noteLayer = new OpenLayers.Layer.Vector("Notes", {
+ visibility: false,
+ projection: new OpenLayers.Projection("EPSG:4326"),
+ styleMap: new OpenLayers.StyleMap(new OpenLayers.Style({
+ graphicWidth: 22,
+ graphicHeight: 22,
+ graphicOpacity: 0.7,
+ graphicXOffset: -11,
+ graphicYOffset: -11
+ }, {
+ rules: [
+ new OpenLayers.Rule({
+ filter: new OpenLayers.Filter.Comparison({
+ type: OpenLayers.Filter.Comparison.EQUAL_TO,
+ property: "status",
+ value: "open"
+ }),
+ symbolizer: {
+ externalGraphic: "<%= image_path 'open_note_marker.png' %>"
+ }
+ }),
+ new OpenLayers.Rule({
+ filter: new OpenLayers.Filter.Comparison({
+ type: OpenLayers.Filter.Comparison.EQUAL_TO,
+ property: "status",
+ value: "closed"
+ }),
+ symbolizer: {
+ externalGraphic: "<%= image_path 'closed_note_marker.png' %>"
+ }
+ })
+ ]
+ })),
+ strategies: [
+ new OpenLayers.Strategy.BBOX()
+ ],
+ protocol: new OpenLayers.Protocol.HTTP({
+ url: "<%= url_for :controller => :note, :action => :list, :format => :json %>",
+ format: new OpenLayers.Format.GeoJSON(),
+ callback: noteCallback
+ })
});
- map.addLayer(map.osbLayer);
+ map.noteLayer.events.register("featureselected", map, noteSelected);
+ map.noteLayer.events.register("featureunselected", map, noteUnselected);
+ map.addLayer(map.noteLayer);
- map.osbControl = new OpenLayers.Control.OpenStreetBugs(map.osbLayer);
- map.addControl(map.osbControl);
+ var noteControl = new OpenLayers.Control.SelectFeature(map.noteLayer, {
+ autoActivate: true
+ });
+ map.addControl(noteControl);
+
+ <% if params[:notes] == "yes" -%>
+ map.noteLayer.setVisibility(true);
+ <% end -%>
- $("reportbuganchor").observe("click", addBug);
+ $("createnoteanchor").observe("click", addNote);
- map.events.register("zoomend", map, allowBugReports);
+ map.events.register("zoomend", map, allowNoteReports);
<% end %>
<% unless object_zoom %>
@@ -292,16 +331,42 @@ end
<% end %>
}
- function addBug() {
- map.osbControl.activate();
- map.osbControl.addTemporaryMarker(map.getCenter());
+ function noteCallback(scope, response) {
+ for (var f = 0; f < response.features.length; f++) {
+ var feature = response.features[f];
+ }
+ }
+
+ function noteSelected(o) {
+ var feature = o.feature;
+ var location = feature.geometry.getBounds().getCenterLonLat();
+
+ feature.popup = new OpenLayers.Popup.FramedCloud(feature.attributes.id,
+ location, null,
+ "" + feature.attributes.id + "
",
+ null, true);
+
+ map.addPopup(feature.popup);
+// feature.popup.show();
+ }
+
+ function noteUnselected(o) {
+ var feature = o.feature;
+
+ map.removePopup(feature.popup);
+ delete feature.popup;
+ }
+
+ function addNote() {
+ map.noteLayer.setVisibility(true);
+ map.noteLayer.addNote(map.getCenter());
}
- function allowBugReports() {
+ function allowNoteReports() {
if (map.getZoom() > 11) {
- $("reportbuganchor").style.visibility = "visible";
+ $("createnoteanchor").style.visibility = "visible";
} else {
- $("reportbuganchor").style.visibility = "hidden";
+ $("createnoteanchor").style.visibility = "hidden";
}
}