1 <% if @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
2 <% content_for :greeting do %>
3 <%= link_to t("layouts.home"), "#", :class => "set_position", :data => { :lat => @user.home_lat, :lon => @user.home_lon, :zoom => 15 }, :title => t("layouts.home_tooltip") %> |
7 <% unless STATUS == :api_offline or STATUS == :database_offline -%>
8 <% content_for :editmenu do -%>
9 <li><%= link_to t("browse.start_rjs.notes_layer_name"), "#", :id => "show_notes" %></li>
10 <li><%= link_to t("browse.start_rjs.data_layer_name"), { :controller => :browse, :action => :start }, :id => "show_data" %></li>
14 <%= render :partial => 'sidebar' %>
15 <%= render :partial => 'key' %>
16 <%= render :partial => 'search' %>
20 <p><%= t 'site.index.js_1' %></p>
21 <p><%= t 'site.index.js_2' %></p>
27 <a href="/" id="permalinkanchor" class="geolink llz layers object"><%= t 'site.index.permalink' %></a>
28 <a href="/" id="shortlinkanchor"><%= t 'site.index.shortlink' %></a>
29 <a href="#" id="createnoteanchor">Report a problem</a>
33 <iframe id="linkloader" style="display: none">
36 <div id="attribution">
39 <td class="attribution_license"><%= t'site.index.license.license_url' %></td>
40 <td class="attribution_project"><%= t'site.index.license.project_url' %></td>
43 <td colspan="2" class="attribution_notice"><%= t'site.index.license.copyright' %></td>
48 <div id="new-note" class="hidden"><%= render :partial => "notes/new" %></div>
50 <script type="text/javascript">
53 var params = OSM.mapParams();
56 var loginName = "<%= @user.display_name %>"
60 map = createMap("map");
62 <% unless STATUS == :api_offline or STATUS == :database_offline %>
63 map.dataLayer = new OpenLayers.Layer("<%= I18n.t 'browse.start_rjs.data_layer_name' %>", {
65 displayInLayerSwitcher: false
67 map.addLayer(map.dataLayer);
69 map.noteLayer = addNoteLayer(map, "<%= notes_url :format => 'json' %>", $("#createnoteanchor"), $("#new-note"), 11);
71 <% if params[:notes] == "yes" -%>
72 map.noteLayer.setVisibility(true);
76 if (!params.object_zoom) {
78 var bbox = new OpenLayers.Bounds(params.minlon, params.minlat, params.maxlon, params.maxlat);
80 map.zoomToExtent(proj(bbox));
83 $(window).load(function() { addBoxToMap(bbox) });
86 setMapCenter(new OpenLayers.LonLat(params.lon, params.lat), params.zoom);
91 setMapLayers(params.layers);
95 marker = addMarkerToMap(new OpenLayers.LonLat(params.mlon, params.mlat));
99 var url = "/api/" + OSM.API_VERSION + "/" + params.object_type + "/" + params.object_id;
101 if (params.object_type != "node") {
105 $(window).load(function() { addObjectToMap(url, params.object_zoom) });
108 map.events.register("moveend", map, updateLocation);
109 map.events.register("changelayer", map, updateLocation);
115 $(document).ready(function () {
116 $("#show_notes").click(function () {
117 map.noteLayer.setVisibility(true);
120 $("#show_data").click(function (e) {
121 $.ajax({ url: $(this).attr('href'), success: function (sidebarHtml) {
122 startBrowse(sidebarHtml);
127 $("body").on("click", "a.set_position", function () {
128 var lat = parseFloat($(this).attr("data-lat"));
129 var lon = parseFloat($(this).attr("data-lon"));
130 var zoom = parseInt($(this).attr("data-zoom"));
131 var min_lon = parseFloat($(this).attr("data-min-lon"));
132 var min_lat = parseFloat($(this).attr("data-min-lat"));
133 var max_lon = parseFloat($(this).attr("data-max-lon"));
134 var max_lat = parseFloat($(this).attr("data-max-lat"));
135 var centre = new OpenLayers.LonLat(lon, lat);
137 if (min_lon && min_lat && max_lon && max_lat) {
138 var bbox = new OpenLayers.Bounds(min_lon, min_lat, max_lon, max_lat);
140 map.zoomToExtent(proj(bbox));
142 setMapCenter(centre, zoom);
146 removeMarkerFromMap(marker);
149 marker = addMarkerToMap(centre, getArrowIcon());
155 function updateLocation() {
156 var lonlat = unproj(map.getCenter());
157 var zoom = map.getZoom();
158 var layers = getMapLayers();
159 var extents = unproj(map.getExtent());
160 var expiry = new Date();
162 updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents.left, extents.bottom, extents.right, extents.top, params.object_type, params.object_id);
164 expiry.setYear(expiry.getFullYear() + 10);
165 $.cookie("_osm_location", [lonlat.lon, lonlat.lat, zoom, layers].join("|"), {expires: expiry});
168 function remoteEditHandler(event) {
169 var extent = unproj(map.getExtent());
172 $("#linkloader").load(function () { loaded = true; });
173 $("#linkloader").attr("src", "http://127.0.0.1:8111/load_and_zoom?left=" + extent.left + "&top=" + extent.top + "&right=" + extent.right + "&bottom=" + extent.bottom);
175 setTimeout(function () {
176 if (!loaded) alert("<%=j t('site.index.remote_failed') %>");
182 function installEditHandler() {
183 $("#remoteanchor").click(remoteEditHandler);
185 <% if preferred_editor == "remote" %>
186 $("#editanchor").click(remoteEditHandler);
188 <% if params[:action] == "edit" %>
194 $(document).ready(mapInit);
195 $(document).ready(installEditHandler);
196 $(document).ready(handleResize);
198 $(window).resize(function() {
199 var centre = map.getCenter();
200 var zoom = map.getZoom();
204 map.setCenter(centre, zoom);
207 $(document).ready(function () {
208 $("#exportanchor").click(function (e) {
209 $.ajax({ url: "<%= url_for :controller => :export, :action => :start %>", success: function (sidebarHtml) {
210 startExport(sidebarHtml);
215 <% if params[:export] -%>
216 $("#exportanchor").click();
219 <% if params[:query] -%>
220 doSearch("<%= params[:query] %>");