2 # Decide on a lat lon to initialise the map with
3 if params['lon'] and params['lat']
6 zoom = h(params['zoom'] || '5')
7 layers = h(params['layers'])
10 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
11 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
12 <%= javascript_include_tag 'map.js' %>
14 <% if big_map.instance_of? Changeset or big_map.visible %>
15 <div id="big_map" style="right: 0; left: 0; bottom: 0; top: 0; position: absolute; border: solid 1px black">
17 <a href="<%= url_for :controller => 'browse', :action => (big_map.class.to_s.downcase + '_map'), :id => big_map.id, :only_path => true %>" id="permalinkanchor"><%= t 'site.index.permalink' %></a><br/>
21 <%= t 'browse.map.deleted' %>
24 <% if big_map.instance_of? Changeset or big_map.visible %>
25 <script type="text/javascript">
28 OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
30 /* A version of index.html.erb->updateLocation that doesn't set a cookie */
31 function updateBigmapLocation() {
32 var lonlat = getMapCenter();
33 var zoom = big_map.getZoom();
34 var layers = getMapLayers();
35 var extents = getMapExtent();
36 var expiry = new Date();
38 updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents.left, extents.bottom, extents.right, extents.top);
42 big_map = createMap("big_map", {
44 new OpenLayers.Control.ArgParser(),
45 new OpenLayers.Control.Attribution(),
46 new OpenLayers.Control.LayerSwitcher(),
47 new OpenLayers.Control.Navigation(),
48 new OpenLayers.Control.PanZoomBar(),
49 new OpenLayers.Control.ScaleLine()
53 <% if big_map.instance_of? Changeset %>
54 var minlon = <%= big_map.min_lon / GeoRecord::SCALE.to_f %>;
55 var minlat = <%= big_map.min_lat / GeoRecord::SCALE.to_f %>;
56 var maxlon = <%= big_map.max_lon / GeoRecord::SCALE.to_f %>;
57 var maxlat = <%= big_map.max_lat / GeoRecord::SCALE.to_f %>;
58 var bbox = new OpenLayers.Bounds(minlon, minlat, maxlon, maxlat);
60 <% if lat and lon and zoom %>
61 var center = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
62 var zoom = <%= zoom %>;
68 <% if !layers.nil? and !layers.empty? %>
69 setMapLayers("<%= layers %>");
73 var obj_type = "<%= big_map.class.name.downcase %>";
74 var obj_id = <%= big_map.id %>;
75 var url = "/api/<%= "#{API_VERSION}" %>/<%= big_map.class.name.downcase %>/<%= big_map.id %>";
77 if (obj_type != "node") {
81 var osm_layer = new OpenLayers.Layer.GML("OSM", url, {
82 format: OpenLayers.Format.OSM,
83 projection: new OpenLayers.Projection("EPSG:4326")
86 osm_layer.events.register("loadend", osm_layer, function() {
87 var extent = this.features[0].geometry.getBounds();
89 for (var i = 1; i < this.features.length; i++) {
90 extent.extend(this.features[i].geometry.getBounds());
93 <% if lat and lon and zoom %>
94 var center = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
95 var zoom = <%= zoom %>;
98 this.map.zoomToExtent(extent);
100 this.map.zoomToMaxExtent();
104 var center = getMapCenter();
107 big_map.addLayer(osm_layer);
110 osm_layer.loaded = true;
112 big_map.events.register("moveend", big_map, updateBigmapLocation);
113 big_map.events.register("changelayer", big_map, updateBigmapLocation);
114 updateBigmapLocation();
117 window.onload = init;