import("system.vars");
import("system.util");
import("system.fileIO");
import("system.result");

var config = {
    startingCenterPosition : {
        lat: parseFloat(vars.get("$param.MapViewCenterLat_param")),
        lon: parseFloat(vars.get("$param.MapViewCenterLon_param")),
        zoomLevel: 5,
        //but let's try to locate the users posistion for a better view
        autoLocate: true
    },
    boundaries: {
        minZoom: 0,
        maxZoom: 20
    },
    tiles: [
            {
        title: "Open Street Map",
        url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
        attribution: "Map data © <a href=\"https://openstreetmap.org\">OpenStreetMap</a> contributors"
    }
    ]
};

//when opening the AroundLocation view we do want to have the source organisation as center, so let's not overwrite the starting center position by 
//looking for the users current location
if (vars.get("$param.MapViewAdditionalFeatures_param"))
{
   config.startingCenterPosition.zoomLevel = 10;//max amount of km is 100, so let's zoom in
   config.startingCenterPosition.autoLocate = false;
}

var res = JSON.stringify(config);
result.string(res);