<div id="map">
<div id="permalink">
- <a href="/" id="permalinkanchor" class="geolink llz layers object"><%= t 'site.index.permalink' %></a><br/>
+ <a href="/" id="permalinkanchor" class="geolink llz layers object"><%= t 'site.index.permalink' %></a>
<a href="/" id="shortlinkanchor"><%= t 'site.index.shortlink' %></a>
+ <a href="#" id="createnoteanchor">Report a problem</a>
</div>
</div>
OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
+ <% if @user %>
+ var loginName = "<%= @user.display_name %>"
+ <% end %>
+
function mapInit(){
map = createMap("map");
map.dataLayer = new OpenLayers.Layer("<%= I18n.t 'browse.start_rjs.data_layer_name' %>", { "visibility": false });
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);
+
+ <% if params[:notes] == "yes" -%>
+ map.noteLayer.setVisibility(true);
+ <% end -%>
+
+ $("#createnoteanchor").click(addNote);
+
+ map.events.register("zoomend", map, allowNoteReports);
<% end %>
<% unless object_zoom %>
setMapExtent(bbox);
<% if box %>
- Event.observe(window, "load", function() { addBoxToMap(bbox) });
+ $(window).load(function() { addBoxToMap(bbox) });
<% end %>
<% else %>
var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
url += "/full";
<% end %>
- Event.observe(window, "load", function() { addObjectToMap(url, <%= object_zoom %>) });
+ $(window).load(function() { addObjectToMap(url, <%= object_zoom %>) });
<% end %>
map.events.register("moveend", map, updateLocation);
function toggleData() {
if (map.dataLayer.visibility) {
- <%= remote_function :url => { :controller => 'browse', :action => 'start' } %>
+ $.ajax({ url: "<%= url_for :controller => :browse, :action => :start %>" });
} else if (map.dataLayer.active) {
closeSidebar();
}
var extent = getMapExtent();
var loaded = false;
- $("linkloader").observe("load", function () { loaded = true; });
- $("linkloader").src = "http://127.0.0.1:8111/load_and_zoom?left=" + extent.left + "&top=" + extent.top + "&right=" + extent.right + "&bottom=" + extent.bottom;
+ $("#linkloader").load(function () { loaded = true; });
+ $("#linkloader").attr("src", "http://127.0.0.1:8111/load_and_zoom?left=" + extent.left + "&top=" + extent.top + "&right=" + extent.right + "&bottom=" + extent.bottom);
setTimeout(function () {
- if (!loaded) alert("<%= escape_javascript(t('site.index.remote_failed')) %>");
+ if (!loaded) alert("<%=j t('site.index.remote_failed') %>");
}, 1000);
- event.stop();
+ return false;
}
function installEditHandler() {
- $("remoteanchor").observe("click", remoteEditHandler);
+ $("#remoteanchor").click(remoteEditHandler);
<% if preferred_editor == "remote" %>
- $("editanchor").observe("click", remoteEditHandler);
+ $("#editanchor").click(remoteEditHandler);
<% if params[:action] == "edit" %>
remoteEditHandler();
<% end %>
}
- document.observe("dom:loaded", mapInit);
- document.observe("dom:loaded", installEditHandler);
- document.observe("dom:loaded", handleResize);
+ 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,
+ "<p>" + feature.attributes.id + "</p>",
+ null, true, function (e) { map.noteControl.unselect(feature) }
+ );
+
+ map.addPopup(feature.popup);
+// feature.popup.show();
+ }
+
+ function noteUnselected(o) {
+ var feature = o.feature;
- Event.observe(window, "resize", function() {
+ 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);
+
+ $(window).resize(function() {
var centre = map.getCenter();
var zoom = map.getZoom();
map.setCenter(centre, zoom);
});
- document.observe("dom:loaded", function () {
- $("exportanchor").observe("click", function (e) {
- <%= remote_function :url => { :controller => 'export', :action => 'start' } %>;
+ $(document).ready(function () {
+ $("#exportanchor").click(function (e) {
+ $.ajax({ url: "<%= url_for :controller => :export, :action => :start %>" });
Event.stop(e);
});
- <% if params[:action] == 'export' %>
- <%= remote_function :url => { :controller => 'export', :action => 'start' } %>;
+ <% if params[:action] == 'export' -%>
+ $.ajax({ url: "<%= url_for :controller => :export, :action => :start %>" });
+ <% end -%>
+
+ <% if params[:query] -%>
+ doSearch("<%= params[:query] %>");
<% end %>
});
// -->