# ILocation.Calculate()

Description:

The `Calculate` method performs mathematical calculations based on a source location and a target location.

This is a synchronous method.

Syntax:

    result = so.ILocation.Calculate(criteria);

Arguments:

- `criteria`:

  This is an object that specifies the mathematical operation to perform and the input values to use in the operation. For more information about the object properties and how to define them, see section Calculation criteria.

Return value:

The `Calculate` method returns an object that contains the calculation results, an error code, and an error message.

Table: Return value properties for Calculate
Property | Description | Value
--- | --- | ---
`result.ReturnValue` | This contains the results for the requested mathematical operation. The type of the value depends on the operation. | See Calculation results.
`result.ErrorCode` | This is a number that specifies a predefined error code. | See Service API error codes.
`result.ErrorMessage` | This is a text string that describes the error. | See Location Service API error messages.

Remarks:

The WGS 84 datum is used to reference coordinates.

Example code:

For the complete source of a sample widget that demonstrates how to use this Service API, see the full example.