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 <script type="text/javascript">
51 var params = OSM.mapParams();
54 var loginName = "<%= @user.display_name %>"
58 map = createMap("map");
60 <% unless STATUS == :api_offline or STATUS == :database_offline %>
61 map.dataLayer = new OpenLayers.Layer("<%= I18n.t 'browse.start_rjs.data_layer_name' %>", {
63 displayInLayerSwitcher: false
65 map.addLayer(map.dataLayer);
67 map.noteLayer = addNoteLayer(map, "<%= notes_url :format => 'json' %>", $("#createnoteanchor"), 11);
69 <% if params[:notes] == "yes" -%>
70 map.noteLayer.setVisibility(true);
74 if (!params.object_zoom) {
76 var bbox = new OpenLayers.Bounds(params.minlon, params.minlat, params.maxlon, params.maxlat);
78 map.zoomToExtent(proj(bbox));
81 $(window).load(function() { addBoxToMap(bbox) });
84 setMapCenter(new OpenLayers.LonLat(params.lon, params.lat), params.zoom);
89 setMapLayers(params.layers);
93 marker = addMarkerToMap(new OpenLayers.LonLat(params.mlon, params.mlat));
97 var url = "/api/" + OSM.API_VERSION + "/" + params.object_type + "/" + params.object_id;
99 if (params.object_type != "node") {
103 $(window).load(function() { addObjectToMap(url, params.object_zoom) });
106 map.events.register("moveend", map, updateLocation);
107 map.events.register("changelayer", map, updateLocation);
113 $(document).ready(function () {
114 $("#show_notes").click(function () {
115 map.noteLayer.setVisibility(true);
118 $("#show_data").click(function (e) {
119 $.ajax({ url: $(this).attr('href'), success: function (sidebarHtml) {
120 startBrowse(sidebarHtml);
125 $("body").on("click", "a.set_position", function () {
126 var lat = parseFloat($(this).attr("data-lat"));
127 var lon = parseFloat($(this).attr("data-lon"));
128 var zoom = parseInt($(this).attr("data-zoom"));
129 var min_lon = parseFloat($(this).attr("data-min-lon"));
130 var min_lat = parseFloat($(this).attr("data-min-lat"));
131 var max_lon = parseFloat($(this).attr("data-max-lon"));
132 var max_lat = parseFloat($(this).attr("data-max-lat"));
133 var centre = new OpenLayers.LonLat(lon, lat);
135 if (min_lon && min_lat && max_lon && max_lat) {
136 var bbox = new OpenLayers.Bounds(min_lon, min_lat, max_lon, max_lat);
138 map.zoomToExtent(proj(bbox));
140 setMapCenter(centre, zoom);
144 removeMarkerFromMap(marker);
147 marker = addMarkerToMap(centre, getArrowIcon());
153 function updateLocation() {
154 var lonlat = unproj(map.getCenter());
155 var zoom = map.getZoom();
156 var layers = getMapLayers();
157 var extents = unproj(map.getExtent());
158 var expiry = new Date();
160 updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents.left, extents.bottom, extents.right, extents.top, params.object_type, params.object_id);
162 expiry.setYear(expiry.getFullYear() + 10);
163 $.cookie("_osm_location", [lonlat.lon, lonlat.lat, zoom, layers].join("|"), {expires: expiry});
166 function remoteEditHandler(event) {
167 var extent = unproj(map.getExtent());
170 $("#linkloader").load(function () { loaded = true; });
171 $("#linkloader").attr("src", "http://127.0.0.1:8111/load_and_zoom?left=" + extent.left + "&top=" + extent.top + "&right=" + extent.right + "&bottom=" + extent.bottom);
173 setTimeout(function () {
174 if (!loaded) alert("<%=j t('site.index.remote_failed') %>");
180 function installEditHandler() {
181 $("#remoteanchor").click(remoteEditHandler);
183 <% if preferred_editor == "remote" %>
184 $("#editanchor").click(remoteEditHandler);
186 <% if params[:action] == "edit" %>
192 $(document).ready(mapInit);
193 $(document).ready(installEditHandler);
194 $(document).ready(handleResize);
196 $(window).resize(function() {
197 var centre = map.getCenter();
198 var zoom = map.getZoom();
202 map.setCenter(centre, zoom);
205 $(document).ready(function () {
206 $("#exportanchor").click(function (e) {
207 $.ajax({ url: "<%= url_for :controller => :export, :action => :start %>", success: function (sidebarHtml) {
208 startExport(sidebarHtml);
213 <% if params[:export] -%>
214 $("#exportanchor").click();
217 <% if params[:query] -%>
218 doSearch("<%= params[:query] %>");