Author: kake Date: 2012-05-05 12:34:21 +0100 (Sat, 05 May 2012) New Revision: 1385
Modified: trunk/static/map-leaflet.js trunk/templates/map_index_leaflet.tt Log: Use fitBounds to do map index zoom; also, only load OSM layer by default, for faster loading.
Modified: trunk/static/map-leaflet.js =================================================================== --- trunk/static/map-leaflet.js 2012-05-05 10:57:04 UTC (rev 1384) +++ trunk/static/map-leaflet.js 2012-05-05 11:34:21 UTC (rev 1385) @@ -1,4 +1,4 @@ -var centre_lat, centre_long, map, map_div_id; +var centre_lat, centre_long, min_lat, min_long, max_lat, max_long, map, map_div_id; var positions = [], markers = [];
var gicon = L.Icon.extend( { @@ -24,10 +24,17 @@
map = new L.Map( map_div_id, { center: map_centre, - zoom: 13, - layers: [ mapquest_layer, osm_layer ], + layers: [ osm_layer ], } );
+ if ( min_lat ) { + var bounds = new L.LatLngBounds( new L.LatLng( min_lat, min_long ), + new L.LatLng( max_lat, max_long ) ); + map.fitBounds( bounds ); + } else { + map.setView( map_centre, 13 ); + } + var layersControl = new L.Control.Layers( { "MapQuest": mapquest_layer, "OpenStreetMap": osm_layer,
Modified: trunk/templates/map_index_leaflet.tt =================================================================== --- trunk/templates/map_index_leaflet.tt 2012-05-05 10:57:04 UTC (rev 1384) +++ trunk/templates/map_index_leaflet.tt 2012-05-05 11:34:21 UTC (rev 1385) @@ -57,6 +57,10 @@ map_div_id = 'map_index_canvas'; centre_lat = [% centre_lat %]; centre_long = [% centre_long %]; + min_lat = [% min_lat %]; + max_lat = [% max_lat %]; + min_long = [% min_long %]; + max_long = [% max_long %];
function add_markers() { var node;