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 <script type="text/javascript">
15 OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
18 var map = createMap("small_map", {
19 controls: [ new OpenLayers.Control.Navigation() ]
22 <% if map.instance_of? Changeset %>
23 var minlon = <%= map.min_lon / GeoRecord::SCALE.to_f %>;
24 var minlat = <%= map.min_lat / GeoRecord::SCALE.to_f %>;
25 var maxlon = <%= map.max_lon / GeoRecord::SCALE.to_f %>;
26 var maxlat = <%= map.max_lat / GeoRecord::SCALE.to_f %>;
27 var bbox = new OpenLayers.Bounds(minlon, minlat, maxlon, maxlat);
32 $("loading").innerHTML = "";
34 $("larger_map").href = '/?minlon='+minlon+'&minlat='+minlat+'&maxlon='+maxlon+'&maxlat='+maxlat+'&box=yes';
35 $("larger_map").innerHTML = "<%= t 'browse.map.view_larger_map' %>";
37 var obj_type = "<%= map.class.name.downcase %>";
38 var obj_id = <%= map.id %>;
39 var url = "/api/<%= "#{API_VERSION}" %>/<%= map.class.name.downcase %>/<%= map.id %>";
41 if (obj_type != "node") {
45 var osm_layer = new OpenLayers.Layer.GML("OSM", url, {
46 format: OpenLayers.Format.OSM,
47 projection: new OpenLayers.Projection("EPSG:4326")
50 osm_layer.events.register("loadend", osm_layer, function() {
51 $("loading").innerHTML = "";
53 if (this.features.length) {
54 var extent = this.features[0].geometry.getBounds();
56 for (var i = 1; i < this.features.length; i++) {
57 extent.extend(this.features[i].geometry.getBounds());
61 this.map.zoomToExtent(extent);
63 this.map.zoomToMaxExtent();
66 var center = getMapCenter();
67 $("larger_map").href = '/?lat='+center.lat+'&lon='+center.lon+'&zoom='+this.map.getZoom();
68 $("larger_map").innerHTML = "<%= t 'browse.map.view_larger_map' %>";
70 $("small_map").style.display = "none";
74 map.addLayer(osm_layer);
77 osm_layer.loaded = true;