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