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());
24 this.map.zoomToExtent(extent);
25 var center = getMapCenter();
26 $("larger_map").href = '/?lat='+center.lat+'&lon='+center.lon+'&zoom='+this.map.getZoom();
27 $("larger_map").innerHTML = "View Larger Map";
29 $("small_map").style.display = "none";
32 map.addLayer(osm_layer);
34 osm_layer.loaded = true;
38 <span id="loading">Loading...</span>
39 <a id="larger_map" href=""></a>