Author: kake Date: 2012-04-18 17:09:37 +0100 (Wed, 18 Apr 2012) New Revision: 1356
Modified: trunk/static/map-leaflet.js Log: Added OSM layer as well as MapQuest one.
Modified: trunk/static/map-leaflet.js =================================================================== --- trunk/static/map-leaflet.js 2012-04-18 15:14:22 UTC (rev 1355) +++ trunk/static/map-leaflet.js 2012-04-18 16:09:37 UTC (rev 1356) @@ -12,17 +12,28 @@ $( function() { if ( map_div_id && centre_lat && centre_long ) { - map = new L.Map( map_div_id ); var map_centre = new L.LatLng( centre_lat, centre_long );
var mq_url = 'http://%7Bs%7D.mqcdn.com/tiles/1.0.0/osm/%7Bz%7D/%7Bx%7D/%7By%7D.png'; var subdomains = [ 'otile1', 'otile2', 'otile3', 'otile4' ]; var attrib = 'Data, imagery and map information provided by <a href="http://open.mapquest.co.uk" target="_blank">MapQuest</a>, <a href="http://www.openstreetmap.org/" target="_blank">OpenStreetMap</a> and contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/" target="_blank">CC-BY-SA</a>'; + var mapquest_layer = new L.TileLayer( mq_url, { maxZoom: 18, attribution: attrib, subdomains: subdomains } );
- var tile_layer = new L.TileLayer( mq_url, { maxZoom: 18, attribution: attrib, subdomains: subdomains } ); + var osm_layer = new L.TileLayer( + 'http://%7Bs%7D.tile.openstreetmap.org/%7Bz%7D/%7Bx%7D/%7By%7D.png' );
- map.setView( map_centre, 13 ).addLayer( tile_layer ); + map = new L.Map( map_div_id, { + center: map_centre, + zoom: 13, + layers: [ mapquest_layer, osm_layer ], + } );
+ var layersControl = new L.Control.Layers( { + "MapQuest": mapquest_layer, + "OpenStreetMap": osm_layer, + } ); + map.addControl( layersControl ); + add_markers(); } }