{"size": 1792, "ext": "js", "max_stars_repo_path": "src/Main.js", "max_stars_repo_name": "stophi-dev/MapEmAll", "max_stars_repo_stars_event_min_datetime": "2016-01-02T15:11:50.000Z", "max_stars_repo_stars_event_max_datetime": "2016-01-02T15:11:50.000Z", "max_issues_repo_path": "src/Main.js", "max_issues_repo_name": "stophi-dev/MapEmAll", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Main.js", "max_forks_repo_name": "stophi-dev/MapEmAll", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.4444444444, "max_line_length": 108, "alphanum_fraction": 0.5407366071}
/*
 * MapEmAll is licensed under the conditions of the MIT License (MIT)
 *
 * Copyright (c) 2015-2016 Philip Stöhrer
 *
 * See https://raw.githubusercontent.com/stophi-dev/MapEmAll/master/LICENSE for details.
 */

define([], function () {
    'use strict';
    var providers = {
        bing: 'bing/Bing',
        google: 'google/Google',
        osm: 'osm/OSM'
    };

    var result = {
        center: {latitude: 0, longitude: 0},
        zoomLevel: 5,
        provider: 'osm',
        htmlContainerId: 'MapEmAll',
        bing: {
            credentials: null
        },
        google: {
            credentials: null
        },
        osm: {
            url: 'http://www.openlayers.org/api/OpenLayers.js'
        },
        getMapProviders: function () {
            return Object.keys(providers);
        }
    };

    result.loadMap = function (onMapReadyCallback) {
        onMapReadyCallback = typeof onMapReadyCallback === 'function' ? onMapReadyCallback : function () {};
        var htmlContainer = document.getElementById(result.htmlContainerId);
        if (htmlContainer === null) {
            throw new Error('Did not find element with id "' + result.htmlContainerId + "'");
        }

        var options = {
            center: result.center,
            zoomLevel: result.zoomLevel,
            htmlContainer: htmlContainer,
            bing: {
                credentials: result.credentials
            },
            google: {
                credentials: result.credentials
            },
            osm: {
                url: result.osm.url
            }
        };
        require([providers[result.provider]], function (mapProvider) {
            mapProvider.loadMap.apply(mapProvider, [options, onMapReadyCallback]);
        });
    };

    return result;
});