var linkMapcompName = "{{linkToMapcompName}}";
var min_lat = -85.05112878;
var max_lat = 85.05112878;
var mapPivotToLinkLayer = null;
try {
    mapPivotToLinkLayer = comp(linkMapcompName).layer("MapPivot");
} catch (e) {}
//try {
	if (mapPivotToLinkLayer) {
		mapPivotToLinkLayer.transform.anchorPoint * (Math.pow(2, thisLayer.transform.opacity) / Math.pow(2, mapPivotToLinkLayer.transform.opacity));
	} else {
		var LatLongToPixelXY = function(latitude, longitude) {
			x = (longitude + 180) / 360;
			sinLatitude = Math.sin(latitude * Math.PI / 180);
			y = 0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI);
			mapSize = Math.abs({{tileSize}} << {{maxZL}});
			pixelX = x * mapSize + 0.5;
			pixelY = y * mapSize + 0.5;
			return [pixelX, pixelY];
		}
		var transformLinear = function(ix, ix1, ix2, iy1, iy2) {
			var m = (iy2 - iy1) / (ix2 - ix1);
            var n = (m * -1) * ix1 + iy1;
            var y = m * ix + n;
            return y
		}
        var calcZoomDependent = function(Zoom, valObj, myTime){
            var n = 0;
            var key1 = null;
            var key2 = null;
            if (valObj.numKeys > 0) {
                n = valObj.nearestKey(myTime).index;
                if (valObj.key(n).time > myTime) {
                    n--
                }
                try {
                    var key1 = valObj.key(n);
                    var key2 = valObj.key(n + 1);
                } catch (e) {}
            }
            if ((key1 != null) && (key2 != null)) {
                var scaleVal1 = Zoom.valueAtTime(key1.time);
                var scaleVal2 = Zoom.valueAtTime(key2.time);
                var scaleValAtTime = Zoom.valueAtTime(myTime);
                var scaleValDiff = scaleVal2 - scaleVal1;
                var scaleVal = transformLinear(scaleValAtTime, 0, 100, {{zoomFunctionBorders[1]}}, {{zoomFunctionBorders[0]}});
                var scaleValT = Math.pow(2, scaleVal);
                var scaleValT1 = Math.pow(2, transformLinear(scaleVal1, 0, 100, {{zoomFunctionBorders[1]}}, {{zoomFunctionBorders[0]}}));
                var scaleValT2 = Math.pow(2, transformLinear(scaleVal2, 0, 100, {{zoomFunctionBorders[1]}}, {{zoomFunctionBorders[0]}}));
                if (scaleValDiff != 0) {
                    return transformLinear(scaleValT, scaleValT1, scaleValT2, key1.value, key2.value);
                }
            }
            return valObj.valueAtTime(myTime);
        }
		var controlLayer = comp("{{containingCompName}}").layer("{{mapcompLayerName}}");
		var diffTime = controlLayer.startTime;
		var myTime = time + diffTime;
		var Latitude = controlLayer.effect("Latitude")("ADBE Angle Control-0001");
		var Longitude = controlLayer.effect("Longitude")("ADBE Angle Control-0001");
		var Zoom = controlLayer.effect("Zoom")("ADBE Slider Control-0001");
        var output = [Latitude.valueAtTime(myTime), Longitude.valueAtTime(myTime)];
		output[0] = calcZoomDependent(Zoom, Latitude, myTime);
        output[1] = calcZoomDependent(Zoom, Longitude, myTime);
		output = LatLongToPixelXY(output[0], output[1]);
		output[1] = Math.min(Math.max(output[1], 0), {{tileSize}} * Math.pow(2, {{maxZL}}));
		[output[0], output[1]];
	}
//} catch (e) {
//	value;
//}