<% marker = true %>
<% mlon = params['mlon'] %>
<% mlat = params['mlat'] %>
-<% lon = params['mlon'] %>
-<% lat = params['mlat'] %>
+<% end %>
+
+<% if params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat'] %>
+<% bbox = true %>
+<% minlon = params['minlon'] %>
+<% minlat = params['minlat'] %>
+<% maxlon = params['maxlon'] %>
+<% maxlat = params['maxlat'] %>
+<% end %>
+
+<% if params['lon'] and params['lat'] %>
+<% lon = params['lon'] %>
+<% lat = params['lat'] %>
+<% zoom = params['zoom'] || '5' %>
+<% layers = params['layers'] %>
+<% elsif params['mlon'] and params['mlat'] %>
+<% lon = params['mlon'] %>
+<% lat = params['mlat'] %>
<% zoom = params['zoom'] || '12' %>
-<% elsif @user and params['lon'].nil? and params['lat'].nil? %>
+<% layers = params['layers'] %>
+<% elsif cookies.key?("location") %>
+<% lon,lat,zoom,layers = cookies["location"].value.first.split(",") %>
+<% elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
<% lon = @user.home_lon %>
<% lat = @user.home_lat %>
<% zoom = '10' %>
-<%else%>
-<% lon = params['lon'] || '-0.1' %>
-<% lat = params['lat'] || '51.5' %>
-<% zoom = params['zoom'] || '4' %>
+<% else %>
+<% lon = '-0.1' %>
+<% lat = '51.5' %>
+<% zoom = params['zoom'] || '5' %>
+<% layers = params['layers'] %>
<% end %>
<script type="text/javascript" src="/openlayers/OpenLayers.js"></script>
<script type="text/javascript">
<!--
- var ie6 = ! ( window.addEventListener || window.XMLHttpRequest );
+ var ie = navigator.appName.indexOf("Microsoft Internet Explorer") != -1;
var map;
function init(){
+ var map = createMap("map");
+
+ <% if bbox %>
+ var min = lonLatToMercator(new OpenLayers.LonLat(<%= minlon %>, <%= minlat %>));
+ var max = lonLatToMercator(new OpenLayers.LonLat(<%= maxlon %>, <%= maxlat %>));
+ var bbox = new OpenLayers.Bounds(min.lon, min.lat, max.lon, max.lat);
+
+ map.zoomToExtent(bbox);
+ <% else %>
var centre = lonLatToMercator(new OpenLayers.LonLat(<%= lon %>, <%= lat %>));
var zoom = <%= zoom %>;
zoom = scaleToZoom(<%= params['scale'].to_f() %>);
<% end %>
- var map = createMap("map", centre, zoom);
+ map.setCentre(center, zoom);
+ <% end %>
<% if marker %>
addMarkerToMap(lonLatToMercator(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>)));
<% end %>
+ <% if layers %>
+ setMapLayers("<%= layers %>");
+ <% end %>
+
map.events.register("moveend", map, updateLocation);
updateLocation();
<% end %>
document.getElementById('map_OpenLayers_ViewPort').style.position = 'absolute';
- if ( ie6 ) {
+ if ( ie ) {
handleResize();
}
}
function updateLocation() {
var lonlat = mercatorToLonLat(map.getCenter());
var zoom = map.getZoom();
+ var layers = getMapLayers();
+
+ updatelinks(lonlat.lon, lonlat.lat, zoom, layers);
- updatelinks(lonlat.lon, lonlat.lat, zoom);
+ document.cookie = "location=" + lonlat.lon + "," + lonlat.lat + "," + zoom + "," + layers;
}
function getStyle( el, property ) {
}
map.updateSize();
el.style.display = 'none';
- setTimeout( function() {
- el.style.display = '';
- }, 200 );
+ setTimeout( function() { el.style.display = ''; }, 200 );
}
- if ( ie6 ) {
+ if ( ie ) {
window.onresize = handleResize;
}