1 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
2 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
3 <%= javascript_include_tag 'map.js' %>
4 <div style="float:right">
5 <div id="small_map" style="width:250px; height: 300px; border: solid 1px black">
7 <script type="text/javascript">
9 var obj_type = '<%= type %>';
10 var obj_id = <%= id %>;
11 var url = "/api/<%= "#{API_VERSION}" %>/<%= type %>/<%= id %>";
12 if (obj_type != "node") {
15 var map = createMap('small_map', {controls: [new OpenLayers.Control.Navigation()]});
16 var osm_layer = new OpenLayers.Layer.GML("OSM", url, {format: OpenLayers.Format.OSM, projection: new OpenLayers.Projection("EPSG:4326")});
17 osm_layer.events.register("loadend", osm_layer, function() {
18 $("loading").innerHTML = "";
19 if (this.features.length) {
20 var extent = this.features[0].geometry.getBounds();
21 for (var i = 1; i < this.features.length; i++) {
22 extent.extend(this.features[i].geometry.getBounds());
25 this.map.zoomToExtent(extent);
27 this.map.zoomToMaxExtent();
29 var center = getMapCenter();
30 $("larger_map").href = '/?lat='+center.lat+'&lon='+center.lon+'&zoom='+this.map.getZoom();
31 $("larger_map").innerHTML = "View Larger Map";
33 $("small_map").style.display = "none";
36 map.addLayer(osm_layer);
38 osm_layer.loaded = true;
42 <span id="loading">Loading...</span>
43 <a id="larger_map" href=""></a>