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">Loading...</span>
9 <a id="larger_map" href=""></a>
14 <script type="text/javascript">
16 var map = createMap("small_map", {
17 controls: [ new OpenLayers.Control.Navigation() ]
20 <% if map.instance_of? Changeset %>
21 var minlon = <%= map.min_lon / GeoRecord::SCALE.to_f %>;
22 var minlat = <%= map.min_lat / GeoRecord::SCALE.to_f %>;
23 var maxlon = <%= map.max_lon / GeoRecord::SCALE.to_f %>;
24 var maxlat = <%= map.max_lat / GeoRecord::SCALE.to_f %>;
25 var bbox = new OpenLayers.Bounds(minlon, minlat, maxlon, maxlat);
30 $("loading").innerHTML = "";
32 $("larger_map").href = '/?minlon='+minlon+'&minlat='+minlat+'&maxlon='+maxlon+'&maxlat='+maxlat+'&box=yes';
33 $("larger_map").innerHTML = "View Larger Map";
35 var obj_type = "<%= map.class.name.downcase %>";
36 var obj_id = <%= map.id %>;
37 var url = "/api/<%= "#{API_VERSION}" %>/<%= map.class.name.downcase %>/<%= map.id %>";
39 if (obj_type != "node") {
43 var osm_layer = new OpenLayers.Layer.GML("OSM", url, {
44 format: OpenLayers.Format.OSM,
45 projection: new OpenLayers.Projection("EPSG:4326")
48 osm_layer.events.register("loadend", osm_layer, function() {
49 $("loading").innerHTML = "";
51 if (this.features.length) {
52 var extent = this.features[0].geometry.getBounds();
54 for (var i = 1; i < this.features.length; i++) {
55 extent.extend(this.features[i].geometry.getBounds());
59 this.map.zoomToExtent(extent);
61 this.map.zoomToMaxExtent();
64 var center = getMapCenter();
65 $("larger_map").href = '/?lat='+center.lat+'&lon='+center.lon+'&zoom='+this.map.getZoom();
66 $("larger_map").innerHTML = "View Larger Map";
68 $("small_map").style.display = "none";
72 map.addLayer(osm_layer);
75 osm_layer.loaded = true;