X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/e660e609661edadc1ed5ad49d6e83e936b2f91cd..fe16fec000e8f26127f656bf68c513f2745b4059:/app/views/site/index.html.erb?ds=sidebyside diff --git a/app/views/site/index.html.erb b/app/views/site/index.html.erb index 884896109..118e82ee2 100644 --- a/app/views/site/index.html.erb +++ b/app/views/site/index.html.erb @@ -123,6 +123,7 @@ end <%= javascript_include_tag 'openlayers.js' %> <%= javascript_include_tag 'map.js' %> +<%= javascript_include_tag 'notes.js' %> <%= render :partial => 'resize' %> @@ -144,64 +145,11 @@ end map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData); map.addLayer(map.dataLayer); - 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.noteLayer.events.register("featureselected", map, noteSelected); - map.noteLayer.events.register("featureunselected", map, noteUnselected); - map.addLayer(map.noteLayer); - - map.noteControl = new OpenLayers.Control.SelectFeature(map.noteLayer, { - autoActivate: true - }); - map.addControl(map.noteControl); + var noteLayer = addNoteLayer(map, "<%= notes_url :format => 'json' %>", $("#createnoteanchor"), 11); <% if params[:notes] == "yes" -%> - map.noteLayer.setVisibility(true); + noteLayer.setVisibility(true); <% end -%> - - $("#createnoteanchor").click(addNote); - - map.events.register("zoomend", map, allowNoteReports); <% end %> <% unless object_zoom %> @@ -329,46 +277,6 @@ end <% end %> } - 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, function (e) { map.noteControl.unselect(feature) } - ); - - 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 allowNoteReports() { - if (map.getZoom() > 11) { - $("#createnoteanchor").show(); - } else { - $("#createnoteanchor").hide(); - } - } - $(document).ready(mapInit); $(document).ready(installEditHandler); $(document).ready(handleResize);