1 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
2 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
3 <%= javascript_include_tag 'map.js' %>
5 <% if map.instance_of? Changeset or map.visible %>
6 <div id="small_map" style="width:250px; height: 300px; border: solid 1px black">
8 <span id="loading"><%= t 'browse.map.loading' %></span>
9 <a id="larger_map" href=""></a>
11 <a id="main_map" href=""></a>
13 <%= t 'browse.map.deleted' %>
16 <% if map.instance_of? Changeset or map.visible %>
17 <script type="text/javascript">
18 OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
21 var map = createMap("small_map", {
22 controls: [ new OpenLayers.Control.Navigation() ]
25 <% if map.instance_of? Changeset %>
26 var minlon = <%= map.min_lon / GeoRecord::SCALE.to_f %>;
27 var minlat = <%= map.min_lat / GeoRecord::SCALE.to_f %>;
28 var maxlon = <%= map.max_lon / GeoRecord::SCALE.to_f %>;
29 var maxlat = <%= map.max_lat / GeoRecord::SCALE.to_f %>;
30 var bbox = new OpenLayers.Bounds(minlon, minlat, maxlon, maxlat);
35 $("loading").innerHTML = "";
37 $("larger_map").href = '<%= url_for :controller => 'browse', :action => (map.class.to_s.downcase + '_map'), :id => map.id, :only_path => true %>';
38 $("larger_map").innerHTML = "<%= t 'browse.map.view_larger_map' %>";
40 $("main_map").href = '/?minlon='+minlon+'&minlat='+minlat+'&maxlon='+maxlon+'&maxlat='+maxlat+'&box=yes';
41 $("main_map").innerHTML = "<%= t 'browse.map.view_main_map' %>";
43 var obj_type = "<%= map.class.name.downcase %>";
44 var obj_id = <%= map.id %>;
45 var url = "/api/<%= "#{API_VERSION}" %>/<%= map.class.name.downcase %>/<%= map.id %>";
47 if (obj_type != "node") {
51 var osm_layer = new OpenLayers.Layer.GML("OSM", url, {
52 format: OpenLayers.Format.OSM,
53 projection: new OpenLayers.Projection("EPSG:4326")
56 osm_layer.events.register("loadend", osm_layer, function() {
57 $("loading").innerHTML = "";
59 if (this.features.length) {
60 var extent = this.features[0].geometry.getBounds();
62 for (var i = 1; i < this.features.length; i++) {
63 extent.extend(this.features[i].geometry.getBounds());
67 this.map.zoomToExtent(extent);
69 this.map.zoomToMaxExtent();
72 var center = getMapCenter();
74 $("larger_map").href = '<%= url_for :controller => 'browse', :action => (map.class.to_s.downcase + '_map'), :id => map.id, :only_path => true %>';
75 $("larger_map").innerHTML = "<%= t 'browse.map.view_larger_map' %>";
77 $("main_map").href = '/?lat='+center.lat+'&lon='+center.lon+'&zoom='+this.map.getZoom();
78 $("main_map").innerHTML = "<%= t 'browse.map.view_main_map' %>";
80 $("small_map").style.display = "none";
84 map.addLayer(osm_layer);
87 osm_layer.loaded = true;