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.data_layer_name"), { :controller => :browse, :action => :start }, :id => "show_data" %></li>
13 <%= render :partial => 'sidebar' %>
14 <%= render :partial => 'key' %>
15 <%= render :partial => 'search' %>
19 <p><%= t 'site.index.js_1' %></p>
20 <p><%= t 'site.index.js_2' %></p>
26 <a href="/" id="permalinkanchor" class="geolink llz layers object"><%= t 'site.index.permalink' %></a>
27 <a href="/" id="shortlinkanchor"><%= t 'site.index.shortlink' %></a>
31 <iframe id="linkloader" style="display: none">
34 <div id="attribution">
37 <td class="attribution_license"><%= t'site.index.license.license_url' %></td>
38 <td class="attribution_project"><%= t'site.index.license.project_url' %></td>
41 <td colspan="2" class="attribution_notice"><%= t'site.index.license.copyright' %></td>
46 <script type="text/javascript">
49 var params = OSM.mapParams();
52 map = createMap("map");
54 if (!params.object_zoom) {
56 var bbox = new OpenLayers.Bounds(params.minlon, params.minlat, params.maxlon, params.maxlat);
58 map.zoomToExtent(proj(bbox));
61 $(window).load(function() { addBoxToMap(bbox) });
64 setMapCenter(new OpenLayers.LonLat(params.lon, params.lat), params.zoom);
69 setMapLayers(params.layers);
73 marker = addMarkerToMap(new OpenLayers.LonLat(params.mlon, params.mlat));
77 var url = "/api/" + OSM.API_VERSION + "/" + params.object_type + "/" + params.object_id;
79 if (params.object_type != "node") {
83 $(window).load(function() { addObjectToMap(url, params.object_zoom) });
86 map.events.register("moveend", map, updateLocation);
87 map.events.register("changelayer", map, updateLocation);
93 $(document).ready(function () {
94 $("#show_data").click(function (e) {
95 $.ajax({ url: $(this).attr('href'), success: function (sidebarHtml) {
96 startBrowse(sidebarHtml);
101 $("body").on("click", "a.set_position", function () {
102 var lat = parseFloat($(this).attr("data-lat"));
103 var lon = parseFloat($(this).attr("data-lon"));
104 var zoom = parseInt($(this).attr("data-zoom"));
105 var min_lon = parseFloat($(this).attr("data-min-lon"));
106 var min_lat = parseFloat($(this).attr("data-min-lat"));
107 var max_lon = parseFloat($(this).attr("data-max-lon"));
108 var max_lat = parseFloat($(this).attr("data-max-lat"));
109 var centre = new OpenLayers.LonLat(lon, lat);
111 if (min_lon && min_lat && max_lon && max_lat) {
112 var bbox = new OpenLayers.Bounds(min_lon, min_lat, max_lon, max_lat);
114 map.zoomToExtent(proj(bbox));
116 setMapCenter(centre, zoom);
120 removeMarkerFromMap(marker);
123 marker = addMarkerToMap(centre, getArrowIcon());
129 function updateLocation() {
130 var lonlat = unproj(map.getCenter());
131 var zoom = map.getZoom();
132 var layers = getMapLayers();
133 var extents = unproj(map.getExtent());
134 var expiry = new Date();
136 updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents.left, extents.bottom, extents.right, extents.top, params.object_type, params.object_id);
138 expiry.setYear(expiry.getFullYear() + 10);
139 $.cookie("_osm_location", [lonlat.lon, lonlat.lat, zoom, layers].join("|"), {expires: expiry});
142 function remoteEditHandler(event) {
143 var extent = unproj(map.getExtent());
146 $("#linkloader").load(function () { loaded = true; });
147 $("#linkloader").attr("src", "http://127.0.0.1:8111/load_and_zoom?left=" + extent.left + "&top=" + extent.top + "&right=" + extent.right + "&bottom=" + extent.bottom);
149 setTimeout(function () {
150 if (!loaded) alert("<%=j t('site.index.remote_failed') %>");
156 function installEditHandler() {
157 $("#remoteanchor").click(remoteEditHandler);
159 <% if preferred_editor == "remote" %>
160 $("#editanchor").click(remoteEditHandler);
162 <% if params[:action] == "edit" %>
168 $(document).ready(mapInit);
169 $(document).ready(installEditHandler);
170 $(document).ready(handleResize);
172 $(window).resize(function() {
173 var centre = map.getCenter();
174 var zoom = map.getZoom();
178 map.setCenter(centre, zoom);
181 $(document).ready(function () {
182 $("#exportanchor").click(function (e) {
183 $.ajax({ url: "<%= url_for :controller => :export, :action => :start %>", success: function (sidebarHtml) {
184 startExport(sidebarHtml);
189 <% if params[:export] -%>
190 $("#exportanchor").click();
193 <% if params[:query] -%>
194 doSearch("<%= params[:query] %>");