--- /dev/null
+class BrowseController < ApplicationController
+ before_filter :authorize_web
+ layout 'site'
+ def way_view
+ begin
+ way = Way.find(params[:id])
+
+ @way = way
+ @name = @way.tags['name'].to_s
+ if @name.length == 0:
+ @name = "#" + @way.id.to_s
+ end
+ @title = 'Way | ' + (@name)
+
+ rescue ActiveRecord::RecordNotFound
+ render :nothing => true, :status => :not_found
+ end
+ end
+ def node_view
+ begin
+ node = Node.find(params[:id])
+
+ @node = node
+ @name = @node.tags_as_hash['name'].to_s
+ if @name.length == 0:
+ @name = "#" + @node.id.to_s
+ end
+ @title = 'Node | ' + (@name)
+
+ rescue ActiveRecord::RecordNotFound
+ render :nothing => true, :status => :not_found
+ end
+ end
+end
--- /dev/null
+<%= render :partial => 'map', :locals => { :type => type, :id => obj.id } %>
+<ul>
+<li><%= link_to h("API"), :controller => "api/#{API_VERSION}/"+type, :id => obj.id %></li>
+<li><%= link_to h("History"), :controller => "api/#{API_VERSION}/"+type, :id => obj.id, :action => "history" %></li>
+</ul>
+Last edited: <%= h(obj.timestamp) %><% if obj.user.data_public %>,
+ by <%= link_to h(obj.user.display_name), :controller => 'user', :action => 'view' , :display_name => obj.user.display_name %>
+<% end %>
+
--- /dev/null
+<%= javascript_include_tag '/openlayers/OpenLayers.js' %>
+<%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
+<%= javascript_include_tag 'map.js' %>
+<div style="float:right">
+<div id="small_map" style="width:250px; height: 300px; border: solid 1px black">
+</div>
+<script type="text/javascript">
+ function init() {
+ var obj_type = '<%= type %>';
+ var obj_id = <%= id %>;
+ var url = "/api/<%= "#{API_VERSION}" %>/<%= type %>/<%= id %>";
+ if (obj_type == "way") {
+ url += "/full";
+ }
+ var map = createMap('small_map', {controls: [new OpenLayers.Control.Navigation()]});
+ var osm_layer = new OpenLayers.Layer.GML("OSM", url, {format: OpenLayers.Format.OSM, projection: new OpenLayers.Projection("EPSG:4326")});
+ osm_layer.events.register("loadend", osm_layer, function() {
+ $("loading").innerHTML = "";
+ this.map.zoomToExtent( this.features[0].geometry.getBounds());
+ var center = map.getCenter().clone().transform(this.map.getProjectionObject(), new OpenLayers.Projection("EPSG:4326"));
+ $("larger_map").href = '/?lat='+center.lat+'&lon='+center.lon+'&zoom='+this.map.getZoom();
+ $("larger_map").innerHTML = "View Larger Map";
+ })
+ map.addLayer(osm_layer);
+ osm_layer.loadGML();
+ osm_layer.loaded = true;
+}
+window.onload = init;
+</script>
+<span id="loading">Loading...</span>
+<a id="larger_map" href=""></a>
+</div>
--- /dev/null
+<tr>
+ <td><%= h(tag[0]) %></td><td><%= h(tag[1]) %></td>
+</tr>
+
--- /dev/null
+<% if tags.length != 0 %>
+<table id="keyvalue" cellpadding="3">
+ <tr>
+ <th>Key</th>
+ <th>Value</th>
+ </tr>
+ <%= render :partial => 'tag', :collection => tags %>
+</table>
+<% end %>
--- /dev/null
+<h2>Node Browser: <%= h(@name) %></h2>
+<%= render :partial => 'common', :locals => { :obj => @node, :type => "node" } %>
+<%= render :partial => 'tag_table', :locals => { :tags => @node.tags_as_hash } %>
--- /dev/null
+<h2>Way Browser: <%= h(@name) %></h2>
+<%= render :partial => 'common', :locals => { :obj => @way, :type => "way" } %>
+<%= render :partial => 'tag_table', :locals => { :tags => @way.tags } %>
map.connect "api/#{API_VERSION}/amf", :controller =>'amf', :action =>'talk'
map.connect "api/#{API_VERSION}/swf/trackpoints", :controller =>'swf', :action =>'trackpoints'
+ # Data browsing
+ map.connect '/way/:id', :controller => 'browse', :action => 'way_view', :id => /\d+/
+ map.connect '/node/:id', :controller => 'browse', :action => 'node_view', :id => /\d+/
+
# web site
map.connect '/', :controller => 'site', :action => 'index'
return "/openlayers/";
}
-function createMap(divName) {
+function createMap(divName, options) {
+ if (!options) { options = {} }
map = new OpenLayers.Map(divName, {
- controls: [
+ controls: options.controls || [
new OpenLayers.Control.ArgParser(),
new OpenLayers.Control.Attribution(),
new OpenLayers.Control.LayerSwitcher(),