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 <%= t 'browse.map.deleted' %>
14 <% if map.instance_of? Changeset or map.visible %>
15 <script type="text/javascript">
16 OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
19 var map = createMap("small_map", {
20 controls: [ new OpenLayers.Control.Navigation() ]
23 <% if map.instance_of? Changeset %>
24 var minlon = <%= map.min_lon / GeoRecord::SCALE.to_f %>;
25 var minlat = <%= map.min_lat / GeoRecord::SCALE.to_f %>;
26 var maxlon = <%= map.max_lon / GeoRecord::SCALE.to_f %>;
27 var maxlat = <%= map.max_lat / GeoRecord::SCALE.to_f %>;
28 var bbox = new OpenLayers.Bounds(minlon, minlat, maxlon, maxlat);
33 $("loading").innerHTML = "";
35 $("larger_map").href = '/?minlon='+minlon+'&minlat='+minlat+'&maxlon='+maxlon+'&maxlat='+maxlat+'&box=yes';
36 $("larger_map").innerHTML = "<%= t 'browse.map.view_larger_map' %>";
38 var obj_type = "<%= map.class.name.downcase %>";
39 var obj_id = <%= map.id %>;
40 var url = "/api/<%= "#{API_VERSION}" %>/<%= map.class.name.downcase %>/<%= map.id %>";
42 if (obj_type != "node") {
46 var osm_layer = new OpenLayers.Layer.GML("OSM", url, {
47 format: OpenLayers.Format.OSM,
48 projection: new OpenLayers.Projection("EPSG:4326")
51 osm_layer.events.register("loadend", osm_layer, function() {
52 $("loading").innerHTML = "";
54 if (this.features.length) {
55 var extent = this.features[0].geometry.getBounds();
57 for (var i = 1; i < this.features.length; i++) {
58 extent.extend(this.features[i].geometry.getBounds());
62 this.map.zoomToExtent(extent);
64 this.map.zoomToMaxExtent();
67 var center = getMapCenter();
68 $("larger_map").href = '/?lat='+center.lat+'&lon='+center.lon+'&zoom='+this.map.getZoom();
69 $("larger_map").innerHTML = "<%= t 'browse.map.view_larger_map' %>";
71 $("small_map").style.display = "none";
75 map.addLayer(osm_layer);
78 osm_layer.loaded = true;