Source: bemap-services/bemap-isochrone.js

/**
 * BeNomad BeMap JavaScript API - Routing, Isochrone
 */


/**
* @classdesc
* Base class for isochrone calculation.
* @public
* @constructor
* @abstract
* @param {bemap.Context} context BeMap-JS-API Context. Mandatory.
* @param {object} options see below the available values.
*/
bemap.Isochrone = function(context, options) {
  bemap.Routing.call(this, context, options);

  /**
   * ID of geometry.
   * @type {String}
   * @protected
   */
  this.geometryId = 'isochrone';

  /**
   * Draw a polygon with the polyline array.
   * @type {boolean}
   * @protected
   */
  this.poylineAsPolygon = true;
};
bemap.inherits(bemap.Isochrone, bemap.Routing);

/**
 * Execute the isochrone calculation.
 * @public
 * @param {object} options See below the available values.
 * @param {object} options.geoserver Geoserver name will be used for this computation.
 * @return {bemap.Isochrone} this
 */
bemap.Isochrone.prototype.compute = function(options) {
  this.reset();

  if (this.destinations && this.destinations.length != 1) {
    console.error("Only 1 destionation is required for an isochrone!");
    return;
  }

  var opts = options || {};
  var i = 0;
  var first = true;
  var url = this.ctx.getBaseUrl() + 'bnd';
  var data = 'version=1.0.0&action=routing&mode=MODE_ISOCHRONE&format=json&options=ISOCHRONE_FORWARD,POLYLINE';

  if (this.ctx.isAuthInPost()) {
    data += '&' + this.ctx.getAuthUrlParams();
  } else {
    url += '?' + this.ctx.getAuthUrlParams();
  }

  data += this.buildRequest(opts);

  return this.execute(url, data, opts);
};