Tracking Profiles

Use Search API to find the Nearest POIs using Cordova Plugin

  1. Use Search API to find the Nearest POIs
  2. Use Search API to monitor region around POIs
  3. Use Distance API to retrieve distance and duration value

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 to request the Woosmap Search API. See how to set it the Initializing the plugin section.

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.

JavaScript
        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:

JavaScript
        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

Radius of POI

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

JavaScript
        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:

JavaScript
        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.

JavaScript
        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

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

    
Was this article helpful?
Have more questions? Submit a request