static/main.js
function setupMap( config ) {
    var layerSettings, defaultSettings,
      query = '',
      matchLang = location.search.match( /lang=([-_a-zA-Z]+)/ );

    defaultSettings = {
      maxzoom: 18,

      // TODO: This is UI text, and needs to be translatable.
      attribution: 'Map data &copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap contributors</a>'
    };

    if ( matchLang ) {
      query = '?lang=' + matchLang[ 1 ];
    }
    config = config || {};

    layerSettings = {
      maxZoom: config.maxzoom !== undefined ? config.maxzoom : defaultSettings.maxzoom,

      // TODO: This is UI text, and needs to be translatable.
      attribution: config.attribution !== undefined ? config.attribution : defaultSettings.attribution,

      id: 'map-01'
    };

    // Add a map layer
    L.tileLayer( style + '/{z}/{x}/{y}' + scalex + '.png' + query, layerSettings ).addTo( map );

    // Add a km/miles scale
    L.control.scale().addTo( map );

    // Update the zoom level label
    map.on( 'zoomend', function () {
      document.getElementById( 'zoom-level' ).innerHTML = 'Zoom Level: ' + map.getZoom();
    } );

    // Add current location to URL hash
    new L.Hash( map ); // eslint-disable-line no-new
  }
function setupMap( config ) {
    var layerSettings, defaultSettings,
      query = '',
      matchLang = location.search.match( /lang=([-_a-zA-Z]+)/ );

    defaultSettings = {
      maxzoom: 18,

      // TODO: This is UI text, and needs to be translatable.
      attribution: 'Map data &copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap contributors</a>'
    };

    if ( matchLang ) {
      query = '?lang=' + matchLang[ 1 ];
    }
    config = config || {};

    layerSettings = {
      maxZoom: config.maxzoom !== undefined ? config.maxzoom : defaultSettings.maxzoom,

      // TODO: This is UI text, and needs to be translatable.
      attribution: config.attribution !== undefined ? config.attribution : defaultSettings.attribution,

      id: 'map-01'
    };

    // Add a map layer
    L.tileLayer( style + '/{z}/{x}/{y}' + scalex + '.png' + query, layerSettings ).addTo( map );

    // Add a km/miles scale
    L.control.scale().addTo( map );

    // Update the zoom level label
    map.on( 'zoomend', function () {
      document.getElementById( 'zoom-level' ).innerHTML = 'Zoom Level: ' + map.getZoom();
    } );

    // Add current location to URL hash
    new L.Hash( map ); // eslint-disable-line no-new
  }
function setupMap ( config ) { var layerSettings , defaultSettings , query = '' , matchLang = location . search . match ( / lang=([-_a-zA-Z]+) / ) ; defaultSettings = { maxzoom : 18 , // TODO: This is UI text, and needs to be translatable. attribution : 'Map data &copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap contributors</a>' } ; if ( matchLang ) { query = '?lang=' + matchLang [ 1 ] ; } config = config || { } ; layerSettings = { maxZoom : config . maxzoom !== undefined ? config . maxzoom : defaultSettings . maxzoom , // TODO: This is UI text, and needs to be translatable. attribution : config . attribution !== undefined ? config . attribution : defaultSettings . attribution , id : 'map-01' } ; // Add a map layer L . tileLayer ( style + '/{z}/{x}/{y}' + scalex + '.png' + query , layerSettings ) . addTo ( map ) ; // Add a km/miles scale L . control . scale ( ) . addTo ( map ) ; // Update the zoom level label map . on ( 'zoomend' , function ( ) { document . getElementById ( 'zoom-level' ) . innerHTML = 'Zoom Level: ' + map . getZoom ( ) ; } ) ; // Add current location to URL hash new L . Hash ( map ) ; // eslint-disable-line no-new }
Finishes setting up the map

@param {Object|null} config Config object
@param {string} [config.attribution] Attribution text to show in footer; see below for default
@param {number} [config.maxzoom=18] Maximum zoom level
Finishes setting up the map