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="area_larger_map" href=""></a>
10 <% unless map.instance_of? Changeset %>
12 <a id="object_larger_map" href=""></a>
15 <%= t 'browse.map.deleted' %>
18 <% if map.instance_of? Changeset or map.visible %>
19 <script type="text/javascript">
20 OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
23 var map = createMap("small_map", {
24 controls: [ new OpenLayers.Control.Navigation() ]
27 <% if map.instance_of? Changeset %>
28 var minlon = <%= map.min_lon / GeoRecord::SCALE.to_f %>;
29 var minlat = <%= map.min_lat / GeoRecord::SCALE.to_f %>;
30 var maxlon = <%= map.max_lon / GeoRecord::SCALE.to_f %>;
31 var maxlat = <%= map.max_lat / GeoRecord::SCALE.to_f %>;
32 var bbox = new OpenLayers.Bounds(minlon, minlat, maxlon, maxlat);
37 $("loading").innerHTML = "";
39 $("area_larger_map").href = '/?minlon='+minlon+'&minlat='+minlat+'&maxlon='+maxlon+'&maxlat='+maxlat+'&box=yes';
40 $("area_larger_map").innerHTML = "<%= t 'browse.map.larger.area' %>";
42 var obj_type = "<%= map.class.name.downcase %>";
43 var obj_id = <%= map.id %>;
44 var url = "/api/<%= "#{API_VERSION}" %>/<%= map.class.name.downcase %>/<%= map.id %>";
46 if (obj_type != "node") {
50 var osm_layer = new OpenLayers.Layer.GML("OSM", url, {
51 format: OpenLayers.Format.OSM,
52 projection: new OpenLayers.Projection("EPSG:4326")
55 osm_layer.events.register("loadend", osm_layer, function() {
56 $("loading").innerHTML = "";
58 if (this.features.length) {
59 var extent = this.features[0].geometry.getBounds();
61 for (var i = 1; i < this.features.length; i++) {
62 extent.extend(this.features[i].geometry.getBounds());
66 this.map.zoomToExtent(extent);
68 this.map.zoomToMaxExtent();
71 var center = getMapCenter();
72 $("area_larger_map").href = '/?lat='+center.lat+'&lon='+center.lon+'&zoom='+this.map.getZoom();
73 $("area_larger_map").innerHTML = "<%= t 'browse.map.larger.area' %>";
74 <% unless map.instance_of? Changeset %>
75 $("object_larger_map").href = '/?<%= map.class.to_s.downcase %>=<%= map.id %>';
76 $("object_larger_map").innerHTML = "<%= t('browse.map.larger.' + map.class.to_s.downcase) %>";
79 $("small_map").style.display = "none";
83 map.addLayer(osm_layer);
86 osm_layer.loaded = true;