1 <% if @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
2 <% content_for :greeting do %>
3 <%= link_to_function t('layouts.home'), "setPosition(#{@user.home_lat}, #{@user.home_lon}, 15)", { :title => t('layouts.home_tooltip') } %> |
7 <%= render :partial => 'sidebar', :locals => { :onopen => "resizeMap();", :onclose => "resizeMap();" } %>
8 <%= render :partial => 'key' %>
9 <%= render :partial => 'search' %>
13 <p><%= t 'site.index.js_1' %></p>
14 <p><%= t 'site.index.js_2' %></p>
20 <a href="/" id="permalinkanchor" class="geolink llz layers object"><%= t 'site.index.permalink' %></a>
21 <a href="/" id="shortlinkanchor"><%= t 'site.index.shortlink' %></a>
25 <iframe id="linkloader" style="display: none">
28 <div id="attribution">
31 <td class="attribution_license"><%= t'site.index.license.license_url' %></td>
32 <td class="attribution_project"><%= t'site.index.license.project_url' %></td>
35 <td colspan="2" class="attribution_notice"><%=
36 t'site.index.license.notice',
37 :license_name => t('site.index.license.license_name'),
38 :project_name => t('site.index.license.project_name')
45 if params[:mlon] and params[:mlat]
47 mlon = params[:mlon].to_f
48 mlat = params[:mlat].to_f
51 if params[:node] or params[:way] or params[:relation]
57 object_id = params[:node].to_i
60 object_id = params[:way].to_i
61 elsif params[:relation]
62 object_type = 'relation'
63 object_id = params[:relation].to_i
67 # Decide on a lat lon to initialise the map with. Various ways of doing this
70 minlon, minlat, maxlon, maxlat = params[:bbox].split(",").collect { |c| c.to_f }
71 layers = params[:layers]
72 box = true if params[:box] == "yes"
74 elsif params[:minlon] and params[:minlat] and params[:maxlon] and params[:maxlat]
76 minlon = params[:minlon].to_f
77 minlat = params[:minlat].to_f
78 maxlon = params[:maxlon].to_f
79 maxlat = params[:maxlat].to_f
80 layers = params[:layers]
81 box = true if params[:box]=="yes"
83 elsif params[:lon] and params[:lat]
84 lon = params[:lon].to_f
85 lat = params[:lat].to_f
86 zoom = params.fetch(:zoom, 5).to_i
87 layers = params[:layers]
89 elsif params[:mlon] and params[:mlat]
90 lon = params[:mlon].to_f
91 lat = params[:mlat].to_f
92 zoom = params.fetch(:zoom, 12).to_i
93 layers = params[:layers]
95 elsif cookies.key?("_osm_location")
96 lon,lat,zoom,layers = cookies["_osm_location"].split("|")
97 elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil?
102 unless STATUS == :database_readonly or STATUS == :database_offline
103 session[:location] = OSM::IPLocation(request.env['REMOTE_ADDR']) unless session[:location]
106 if session[:location]
108 minlon = session[:location][:minlon]
109 minlat = session[:location][:minlat]
110 maxlon = session[:location][:maxlon]
111 maxlat = session[:location][:maxlat]
115 zoom = params.fetch(:zoom, 5).to_i
118 layers = params[:layers]
122 <%= javascript_include_tag 'openlayers.js' %>
123 <%= javascript_include_tag 'map.js' %>
125 <%= render :partial => 'resize' %>
127 <script type="text/javascript">
131 OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
134 map = createMap("map");
136 <% unless STATUS == :api_offline or STATUS == :database_offline %>
137 map.dataLayer = new OpenLayers.Layer("<%= I18n.t 'browse.start_rjs.data_layer_name' %>", {
139 displayInLayerSwitcher: false
141 map.addLayer(map.dataLayer);
144 <% unless object_zoom %>
146 var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
148 map.zoomToExtent(proj(bbox));
151 $(window).load(function() { addBoxToMap(bbox) });
154 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
155 <% if params[:scale].to_f > 0 then -%>
156 var zoom = <%= scale_to_zoom params[:scale] %>;
158 var zoom = <%= zoom %>;
161 setMapCenter(centre, zoom);
165 <% if !layers.nil? and !layers.empty? %>
166 setMapLayers("<%= layers %>");
170 marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>));
174 var url = "/api/<%= "#{API_VERSION}" %>/<%= object_type %>/<%= object_id %>";
176 <% if object_type != "node" %>
180 $(window).load(function() { addObjectToMap(url, <%= object_zoom %>) });
183 map.events.register("moveend", map, updateLocation);
184 map.events.register("changelayer", map, updateLocation);
190 function showData() {
191 $.ajax({ url: "<%= url_for :controller => :browse, :action => :start %>" });
194 function setPosition(lat, lon, zoom, min_lon, min_lat, max_lon, max_lat) {
195 var centre = new OpenLayers.LonLat(lon, lat);
197 if (min_lon && min_lat && max_lon && max_lat) {
198 var bbox = new OpenLayers.Bounds(min_lon, min_lat, max_lon, max_lat);
200 map.zoomToExtent(proj(bbox));
202 setMapCenter(centre, zoom);
206 removeMarkerFromMap(marker);
209 marker = addMarkerToMap(centre, getArrowIcon());
212 function updateLocation() {
213 var lonlat = unproj(map.getCenter());
214 var zoom = map.getZoom();
215 var layers = getMapLayers();
216 var extents = unproj(map.getExtent());
217 var expiry = new Date();
222 objtype = "<%= object_type %>";
223 objid = <%= object_id %>;
226 updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents.left, extents.bottom, extents.right, extents.top, objtype, objid);
228 expiry.setYear(expiry.getFullYear() + 10);
229 document.cookie = "_osm_location=" + lonlat.lon + "|" + lonlat.lat + "|" + zoom + "|" + layers + "; expires=" + expiry.toGMTString();
232 function remoteEditHandler(event) {
233 var extent = unproj(map.getExtent());
236 $("#linkloader").load(function () { loaded = true; });
237 $("#linkloader").attr("src", "http://127.0.0.1:8111/load_and_zoom?left=" + extent.left + "&top=" + extent.top + "&right=" + extent.right + "&bottom=" + extent.bottom);
239 setTimeout(function () {
240 if (!loaded) alert("<%=j t('site.index.remote_failed') %>");
246 function installEditHandler() {
247 $("#remoteanchor").click(remoteEditHandler);
249 <% if preferred_editor == "remote" %>
250 $("#editanchor").click(remoteEditHandler);
252 <% if params[:action] == "edit" %>
258 $(document).ready(mapInit);
259 $(document).ready(installEditHandler);
260 $(document).ready(handleResize);
262 $(window).resize(function() {
263 var centre = map.getCenter();
264 var zoom = map.getZoom();
268 map.setCenter(centre, zoom);
271 $(document).ready(function () {
272 $("#exportanchor").click(function (e) {
273 $.ajax({ url: "<%= url_for :controller => :export, :action => :start %>" });
277 <% if params[:action] == 'export' -%>
278 $.ajax({ url: "<%= url_for :controller => :export, :action => :start %>" });
281 <% if params[:query] -%>
282 doSearch("<%= params[:query] %>");