]> git.openstreetmap.org Git - rails.git/blobdiff - app/views/site/index.html.erb
Merge branch 'master' into openid
[rails.git] / app / views / site / index.html.erb
index 40a7a3fbca52e085932194a983ba3ee4ef383e03..ddd66a861553e79b32936b224a70b8bf16e1e876 100644 (file)
@@ -125,7 +125,7 @@ end
   function mapInit(){
     map = createMap("map");
 
-    <% unless OSM_STATUS == :api_offline or OSM_STATUS == :database_offline %>
+    <% unless STATUS == :api_offline or STATUS == :database_offline %>
       map.dataLayer = new OpenLayers.Layer("<%= I18n.t 'browse.start_rjs.data_layer_name' %>", { "visibility": false });
       map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData);
       map.addLayer(map.dataLayer);
@@ -170,7 +170,8 @@ end
         url += "/full";
       <% end %>
 
-      addObjectToMap(url, <%= object_zoom %>);
+      // IE requires Vector layers be initialised on page load, and not under deferred script conditions
+      Event.observe(window, 'load', function() { addObjectToMap(url, <%= object_zoom %>) });
     <% end %>
 
     map.events.register("moveend", map, updateLocation);
@@ -182,7 +183,7 @@ end
   function toggleData() {
     if (map.dataLayer.visibility) {
       <%= remote_function :url => { :controller => 'browse', :action => 'start' } %>
-    } else {
+    } else if (map.dataLayer.active) {
       closeSidebar();
     }
   }
@@ -191,10 +192,20 @@ end
     return getMapCenter();
   }
 
-  function setPosition(lat, lon, zoom) {
+  function getZoom() {
+    return getMapZoom();
+  }
+
+  function setPosition(lat, lon, zoom, min_lon, min_lat, max_lon, max_lat) {
     var centre = new OpenLayers.LonLat(lon, lat);
 
-    setMapCenter(centre, zoom);
+    if (min_lon && min_lat && max_lon && max_lat) {
+      var bbox = new OpenLayers.Bounds(min_lon, min_lat, max_lon, max_lat);
+
+      setMapExtent(bbox);
+    } else {
+      setMapCenter(centre, zoom);
+    }
 
     if (marker)
       removeMarkerFromMap(marker);