1 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
2 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
3 <%= javascript_include_tag 'map.js' %>
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 obj_type = "<%= map.class.name.downcase %>";
17 var obj_id = <%= map.id %>;
18 var url = "/api/<%= "#{API_VERSION}" %>/<%= map.class.name.downcase %>/<%= map.id %>";
20 if (obj_type != "node") {
24 var map = createMap("small_map", {
25 controls: [ new OpenLayers.Control.Navigation() ]
28 var osm_layer = new OpenLayers.Layer.GML("OSM", url, {
29 format: OpenLayers.Format.OSM,
30 projection: new OpenLayers.Projection("EPSG:4326")
33 osm_layer.events.register("loadend", osm_layer, function() {
34 $("loading").innerHTML = "";
36 if (this.features.length) {
37 var extent = this.features[0].geometry.getBounds();
39 for (var i = 1; i < this.features.length; i++) {
40 extent.extend(this.features[i].geometry.getBounds());
44 this.map.zoomToExtent(extent);
46 this.map.zoomToMaxExtent();
49 var center = getMapCenter();
50 $("larger_map").href = '/?lat='+center.lat+'&lon='+center.lon+'&zoom='+this.map.getZoom();
51 $("larger_map").innerHTML = "View Larger Map";
53 $("small_map").style.display = "none";
57 map.addLayer(osm_layer);
60 osm_layer.loaded = true;