1 <% content_for :greeting do %>
2 <% if @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
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>
15 <p><%= t 'site.index.js_3' %></p>
21 <a href="/" id="permalinkanchor" class="geolink llz layers object"><%= t 'site.index.permalink' %></a><br/>
22 <a href="/" id="shortlinkanchor"><%= t 'site.index.shortlink' %></a>
23 <a href="#" id="createnoteanchor">Report a problem</a>
27 <iframe id="linkloader" style="display: none">
30 <div id="attribution">
33 <td class="attribution_license"><%= t'site.index.license.license_url' %></td>
34 <td class="attribution_project"><%= t'site.index.license.project_url' %></td>
37 <td colspan="2" class="attribution_notice"><%=
38 t'site.index.license.notice',
39 :license_name => t('site.index.license.license_name'),
40 :project_name => t('site.index.license.project_name')
47 if params['mlon'] and params['mlat']
49 mlon = h(params['mlon'])
50 mlat = h(params['mlat'])
53 if params['node'] or params['way'] or params['relation']
59 object_id = h(params['node'])
62 object_id = h(params['way'])
63 elsif params['relation']
64 object_type = 'relation'
65 object_id = h(params['relation'])
69 # Decide on a lat lon to initialise the map with. Various ways of doing this
72 minlon, minlat, maxlon, maxlat = h(params['bbox']).split(",")
73 layers = h(params['layers'])
74 box = true if params['box']=="yes"
76 elsif params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat']
78 minlon = h(params['minlon'])
79 minlat = h(params['minlat'])
80 maxlon = h(params['maxlon'])
81 maxlat = h(params['maxlat'])
82 layers = h(params['layers'])
83 box = true if params['box']=="yes"
85 elsif params['lon'] and params['lat']
86 lon = h(params['lon'])
87 lat = h(params['lat'])
88 zoom = h(params['zoom'] || '5')
89 layers = h(params['layers'])
91 elsif params['mlon'] and params['mlat']
92 lon = h(params['mlon'])
93 lat = h(params['mlat'])
94 zoom = h(params['zoom'] || '12')
95 layers = h(params['layers'])
97 elsif cookies.key?("_osm_location")
98 lon,lat,zoom,layers = cookies["_osm_location"].split("|")
99 elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil?
104 unless STATUS == :database_readonly or STATUS == :database_offline
105 session[:location] = OSM::IPLocation(request.env['REMOTE_ADDR']) unless session[:location]
108 if session[:location]
110 minlon = session[:location][:minlon]
111 minlat = session[:location][:minlat]
112 maxlon = session[:location][:maxlon]
113 maxlat = session[:location][:maxlat]
117 zoom = h(params['zoom'] || '5')
120 layers = h(params['layers'])
124 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
125 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
126 <%= javascript_include_tag 'notes.js' %>
127 <%= javascript_include_tag 'map.js' %>
129 <%= render :partial => 'resize' %>
131 <script type="text/javascript">
135 OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
138 var loginName = "<%= @user.display_name %>"
142 map = createMap("map");
144 <% unless STATUS == :api_offline or STATUS == :database_offline %>
145 map.dataLayer = new OpenLayers.Layer("<%= I18n.t 'browse.start_rjs.data_layer_name' %>", { "visibility": false });
146 map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData);
147 map.addLayer(map.dataLayer);
149 map.noteLayer = new OpenLayers.Layer.Notes("Notes", {
151 permalinkURL: "http://www.openstreetmap.org/",
152 visibility: <%= params[:notes] == "yes" %>
154 map.addLayer(map.noteLayer);
156 $("createnoteanchor").observe("click", addNote);
158 map.events.register("zoomend", map, allowNoteReports);
161 <% unless object_zoom %>
163 var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
168 Event.observe(window, "load", function() { addBoxToMap(bbox) });
171 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
172 var zoom = <%= zoom %>;
174 <% if params['scale'] and params['scale'].length > 0 then %>
175 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
178 setMapCenter(centre, zoom);
184 <% if !layers.nil? and !layers.empty? %>
185 setMapLayers("<%= layers %>");
189 marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>));
193 var url = "/api/<%= "#{API_VERSION}" %>/<%= object_type %>/<%= object_id %>";
195 <% if object_type != "node" %>
199 Event.observe(window, "load", function() { addObjectToMap(url, <%= object_zoom %>) });
202 map.events.register("moveend", map, updateLocation);
203 map.events.register("changelayer", map, updateLocation);
208 function toggleData() {
209 if (map.dataLayer.visibility) {
210 <%= remote_function :url => { :controller => 'browse', :action => 'start' } %>
211 } else if (map.dataLayer.active) {
216 function getPosition() {
217 return getMapCenter();
224 function setPosition(lat, lon, zoom, min_lon, min_lat, max_lon, max_lat) {
225 var centre = new OpenLayers.LonLat(lon, lat);
227 if (min_lon && min_lat && max_lon && max_lat) {
228 var bbox = new OpenLayers.Bounds(min_lon, min_lat, max_lon, max_lat);
232 setMapCenter(centre, zoom);
236 removeMarkerFromMap(marker);
238 marker = addMarkerToMap(centre, getArrowIcon());
241 function updateLocation() {
242 var lonlat = getMapCenter();
243 var zoom = map.getZoom();
244 var layers = getMapLayers();
245 var extents = getMapExtent();
246 var expiry = new Date();
251 objtype = "<%= object_type %>";
252 objid = <%= object_id %>;
255 updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents.left, extents.bottom, extents.right, extents.top, objtype, objid);
257 expiry.setYear(expiry.getFullYear() + 10);
258 document.cookie = "_osm_location=" + lonlat.lon + "|" + lonlat.lat + "|" + zoom + "|" + layers + "; expires=" + expiry.toGMTString();
261 function remoteEditHandler(event) {
262 var extent = getMapExtent();
265 $("linkloader").observe("load", function () { loaded = true; });
266 $("linkloader").src = "http://127.0.0.1:8111/load_and_zoom?left=" + extent.left + "&top=" + extent.top + "&right=" + extent.right + "&bottom=" + extent.bottom;
268 setTimeout(function () {
269 if (!loaded) alert("<%= escape_javascript(t('site.index.remote_failed')) %>");
275 function installEditHandler() {
276 $("remoteanchor").observe("click", remoteEditHandler);
278 <% if preferred_editor == "remote" %>
279 $("editanchor").observe("click", remoteEditHandler);
281 <% if params[:action] == "edit" %>
288 map.noteLayer.setVisibility(true);
289 map.noteLayer.addNote(map.getCenter());
292 function allowNoteReports() {
293 if (map.getZoom() > 11) {
294 $("createnoteanchor").style.visibility = "visible";
296 $("createnoteanchor").style.visibility = "hidden";
300 document.observe("dom:loaded", mapInit);
301 document.observe("dom:loaded", installEditHandler);
302 document.observe("dom:loaded", handleResize);
304 Event.observe(window, "resize", function() {
305 var centre = map.getCenter();
306 var zoom = map.getZoom();
310 map.setCenter(centre, zoom);
313 <% if params['action'] == 'export' %>
314 <%= remote_function :url => { :controller => 'export', :action => 'start' } %>