Source: https://developers.woosmap.com/products/geofencing-sdk/cordova-plugin/guides/find-nearest-pois/

> For clean Markdown of any page, append `.md` to the page URL.

> For a complete documentation index, see https://developers.woosmap.com/llms.txt

# Tracking Profiles



## Use Search API to find the Nearest POIs

After receiving the user location, the SDK automatically triggers a request to the Search API to get the nearest POIs (only if `searchAPIRequestEnable = true`).

You need a [Private API key](/api-reference/authentication/#registering-a-woosmap-private-api-key) to request the Woosmap Search API. See how to set it the [Initializing the plugin section.](/products/geofencing-sdk/cordova-plugin/guides/setup/#initializing-the-plugin)

To listen to Search API results, call `watchSearchApi` method. Method will invoke a callback with POI object. Method will return a watch id which can be used later to remove the callback.

```js
const searchApiCallback = function (poi) {
  console.log("POI:" + poi);
};

const error = function (err) {
  console.log(err);
};

var searchAPIWatchId = cordova.plugins.WoosmapGeofencing.watchSearchAPI(searchApiCallback, error);
```

To stop getting Search API updates:

```js
cordova.plugins.WoosmapGeofencing.clearSearchApiWatch(searchAPIWatchId, success, error);
```

## Use Search API to monitor region around POIs

Regions creation is enabled on the nearest result of the Search API request. More details in the [Monitor POIs documentation](/products/geofencing-sdk/cordova-plugin/guides/monitor-pois/#create-regions-from-woosmap-search-api-assets)

### Radius of POI

When you create a Geofence around a POI, manually define the radius value:

```js
const success = function (status) {
  console.log("Status:" + status);
};
const errors = function (err) {
  console.log("Error:" + err);
};
cordova.plugins.WoosmapGeofencing.setPoiRadius(100, success, errors);
```

or choose the user_properties subfield that corresponds to radius value of the Geofence:

```js
const success = function (status) {
  console.log("Status:" + status);
};
const errors = function (err) {
  console.log("Error:" + err);
};
cordova.plugins.WoosmapGeofencing.setPoiRadius("radiusPOI", success, errors);
```

## Use Distance API to retrieve distance and duration value

To listen to Distance API results, call `watchDistanceApi` method. Method will invoke a callback with DistanceAPI object. Method will return a watch id which can be used later to remove the callback.

```js
const distanceApiCallback = function (distanceAPI) {
  console.log("Distance API:" + distanceAPI);
};

const error = function (err) {
  console.log(err);
};

var distanceAPIWatchId = cordova.plugins.WoosmapGeofencing.watchDistanceApi(distanceApiCallback, error);
```

To stop listening

```js
cordova.plugins.WoosmapGeofencing.clearDistanceApiWatch(distanceAPIWatchId, success, error);
```
