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"><%= t 'site.index.permalink' %></a><br/>
22 <a href="/" id="shortlinkanchor"><%= t 'site.index.shortlink' %></a>
26 <iframe id="linkloader" style="display: none">
29 <div id="attribution">
32 <td class="attribution_license"><%= t'site.index.license.license_url' %></td>
33 <td class="attribution_project"><%= t'site.index.license.project_url' %></td>
36 <td colspan="2" class="attribution_notice"><%=
37 t'site.index.license.notice',
38 :license_name => t('site.index.license.license_name'),
39 :project_name => t('site.index.license.project_name')
46 if params['mlon'] and params['mlat']
48 mlon = h(params['mlon'])
49 mlat = h(params['mlat'])
52 if params['node'] or params['way'] or params['relation']
58 object_id = h(params['node'])
61 object_id = h(params['way'])
62 elsif params['relation']
63 object_type = 'relation'
64 object_id = h(params['relation'])
68 # Decide on a lat lon to initialise the map with. Various ways of doing this
69 if params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat']
71 minlon = h(params['minlon'])
72 minlat = h(params['minlat'])
73 maxlon = h(params['maxlon'])
74 maxlat = h(params['maxlat'])
75 layers = h(params['layers'])
76 box = true if params['box']=="yes"
78 elsif params['lon'] and params['lat']
79 lon = h(params['lon'])
80 lat = h(params['lat'])
81 zoom = h(params['zoom'] || '5')
82 layers = h(params['layers'])
84 elsif params['mlon'] and params['mlat']
85 lon = h(params['mlon'])
86 lat = h(params['mlat'])
87 zoom = h(params['zoom'] || '12')
88 layers = h(params['layers'])
90 elsif cookies.key?("_osm_location")
91 lon,lat,zoom,layers = cookies["_osm_location"].split("|")
92 elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil?
97 unless STATUS == :database_readonly or STATUS == :database_offline
98 session[:location] = OSM::IPLocation(request.env['REMOTE_ADDR']) unless session[:location]
101 if session[:location]
103 minlon = session[:location][:minlon]
104 minlat = session[:location][:minlat]
105 maxlon = session[:location][:maxlon]
106 maxlat = session[:location][:maxlat]
110 zoom = h(params['zoom'] || '5')
113 layers = h(params['layers'])
117 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
118 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
119 <%= javascript_include_tag 'map.js' %>
121 <%= render :partial => 'resize' %>
123 <script type="text/javascript">
127 OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
130 map = createMap("map");
132 <% unless STATUS == :api_offline or STATUS == :database_offline %>
133 map.dataLayer = new OpenLayers.Layer("<%= I18n.t 'browse.start_rjs.data_layer_name' %>", { "visibility": false });
134 map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData);
135 map.addLayer(map.dataLayer);
138 <% unless object_zoom %>
140 var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
145 Event.observe(window, "load", function() { addBoxToMap(bbox) });
148 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
149 var zoom = <%= zoom %>;
151 <% if params['scale'] and params['scale'].length > 0 then %>
152 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
155 setMapCenter(centre, zoom);
161 <% if !layers.nil? and !layers.empty? %>
162 setMapLayers("<%= layers %>");
166 marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>));
170 var url = "/api/<%= "#{API_VERSION}" %>/<%= object_type %>/<%= object_id %>";
172 <% if object_type != "node" %>
176 Event.observe(window, "load", function() { addObjectToMap(url, <%= object_zoom %>) });
179 map.events.register("moveend", map, updateLocation);
180 map.events.register("changelayer", map, updateLocation);
185 function toggleData() {
186 if (map.dataLayer.visibility) {
187 <%= remote_function :url => { :controller => 'browse', :action => 'start' } %>
188 } else if (map.dataLayer.active) {
193 function getPosition() {
194 return getMapCenter();
201 function setPosition(lat, lon, zoom, min_lon, min_lat, max_lon, max_lat) {
202 var centre = new OpenLayers.LonLat(lon, lat);
204 if (min_lon && min_lat && max_lon && max_lat) {
205 var bbox = new OpenLayers.Bounds(min_lon, min_lat, max_lon, max_lat);
209 setMapCenter(centre, zoom);
213 removeMarkerFromMap(marker);
215 marker = addMarkerToMap(centre, getArrowIcon());
218 function updateLocation() {
219 var lonlat = getMapCenter();
220 var zoom = map.getZoom();
221 var layers = getMapLayers();
222 var extents = getMapExtent();
223 var expiry = new Date();
228 objtype = "<%= object_type %>";
229 objid = <%= object_id %>;
232 updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents.left, extents.bottom, extents.right, extents.top, objtype, objid);
234 expiry.setYear(expiry.getFullYear() + 10);
235 document.cookie = "_osm_location=" + lonlat.lon + "|" + lonlat.lat + "|" + zoom + "|" + layers + "; expires=" + expiry.toGMTString();
238 function remoteEditHandler(event) {
239 var extent = getMapExtent();
242 $("linkloader").observe("load", function () { loaded = true; });
243 $("linkloader").src = "http://127.0.0.1:8111/load_and_zoom?left=" + extent.left + "&top=" + extent.top + "&right=" + extent.right + "&bottom=" + extent.bottom;
245 setTimeout(function () {
246 if (!loaded) alert("<%= escape_javascript(t('site.index.remote_failed')) %>");
252 function installEditHandler() {
253 $("remoteanchor").observe("click", remoteEditHandler);
255 <% if preferred_editor == "remote" %>
256 $("editanchor").observe("click", remoteEditHandler);
258 <% if params[:action] == "edit" %>
264 document.observe("dom:loaded", mapInit);
265 document.observe("dom:loaded", installEditHandler);
266 document.observe("dom:loaded", handleResize);
268 Event.observe(window, "resize", function() {
269 var centre = map.getCenter();
270 var zoom = map.getZoom();
274 map.setCenter(centre, zoom);
277 <% if params['action'] == 'export' %>
278 <%= remote_function :url => { :controller => 'export', :action => 'start' } %>