How to use the mapbox-gl/dist/mapbox-gl.js.Point function in mapbox-gl

To help you get started, we’ve selected a few mapbox-gl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alex3165 / react-mapbox-gl / src / util / overlays.js View on Github external
const normalizedOffsets = (offset) => {
  if (!offset) {
    return normalizedOffsets(new Point(0, 0));
  }

  if (typeof offset === 'number') {
    // input specifies a radius from which to calculate offsets at all positions
    const cornerOffset = Math.round(Math.sqrt(0.5 * Math.pow(offset, 2)));
    return {
      center: new Point(offset, offset),
      top: new Point(0, offset),
      bottom: new Point(0, -offset),
      left: new Point(offset, 0),
      right: new Point(-offset, 0),
      'top-left': new Point(cornerOffset, cornerOffset),
      'top-right': new Point(-cornerOffset, cornerOffset),
      'bottom-left': new Point(cornerOffset, -cornerOffset),
      'bottom-right': new Point(-cornerOffset, -cornerOffset),
    };
  }

  if (isPointLike(offset)) {
    // input specifies a single offset to be applied to all positions
    return anchors.reduce((res, anchor) => {
      const tmp = Object.assign({}, res);
      tmp[anchor] = Point.convert(offset);
      return tmp;
    }, {});
github alex3165 / react-mapbox-gl / src / util / overlays.js View on Github external
const normalizedOffsets = (offset) => {
  if (!offset) {
    return normalizedOffsets(new Point(0, 0));
  }

  if (typeof offset === 'number') {
    // input specifies a radius from which to calculate offsets at all positions
    const cornerOffset = Math.round(Math.sqrt(0.5 * Math.pow(offset, 2)));
    return {
      center: new Point(offset, offset),
      top: new Point(0, offset),
      bottom: new Point(0, -offset),
      left: new Point(offset, 0),
      right: new Point(-offset, 0),
      'top-left': new Point(cornerOffset, cornerOffset),
      'top-right': new Point(-cornerOffset, cornerOffset),
      'bottom-left': new Point(cornerOffset, -cornerOffset),
      'bottom-right': new Point(-cornerOffset, -cornerOffset),
    };
  }

  if (isPointLike(offset)) {
    // input specifies a single offset to be applied to all positions
    return anchors.reduce((res, anchor) => {
      const tmp = Object.assign({}, res);
      tmp[anchor] = Point.convert(offset);
github alex3165 / react-mapbox-gl / src / util / overlays.js View on Github external
const normalizedOffsets = (offset) => {
  if (!offset) {
    return normalizedOffsets(new Point(0, 0));
  }

  if (typeof offset === 'number') {
    // input specifies a radius from which to calculate offsets at all positions
    const cornerOffset = Math.round(Math.sqrt(0.5 * Math.pow(offset, 2)));
    return {
      center: new Point(offset, offset),
      top: new Point(0, offset),
      bottom: new Point(0, -offset),
      left: new Point(offset, 0),
      right: new Point(-offset, 0),
      'top-left': new Point(cornerOffset, cornerOffset),
      'top-right': new Point(-cornerOffset, cornerOffset),
      'bottom-left': new Point(cornerOffset, -cornerOffset),
      'bottom-right': new Point(-cornerOffset, -cornerOffset),
    };
  }

  if (isPointLike(offset)) {
    // input specifies a single offset to be applied to all positions
    return anchors.reduce((res, anchor) => {
      const tmp = Object.assign({}, res);
      tmp[anchor] = Point.convert(offset);
      return tmp;
    }, {});
  }

  // input specifies an offset per position
github alex3165 / react-mapbox-gl / src / util / overlays.js View on Github external
const normalizedOffsets = (offset) => {
  if (!offset) {
    return normalizedOffsets(new Point(0, 0));
  }

  if (typeof offset === 'number') {
    // input specifies a radius from which to calculate offsets at all positions
    const cornerOffset = Math.round(Math.sqrt(0.5 * Math.pow(offset, 2)));
    return {
      center: new Point(offset, offset),
      top: new Point(0, offset),
      bottom: new Point(0, -offset),
      left: new Point(offset, 0),
      right: new Point(-offset, 0),
      'top-left': new Point(cornerOffset, cornerOffset),
      'top-right': new Point(-cornerOffset, cornerOffset),
      'bottom-left': new Point(cornerOffset, -cornerOffset),
      'bottom-right': new Point(-cornerOffset, -cornerOffset),
    };
  }

  if (isPointLike(offset)) {
    // input specifies a single offset to be applied to all positions
    return anchors.reduce((res, anchor) => {
      const tmp = Object.assign({}, res);
      tmp[anchor] = Point.convert(offset);
      return tmp;
    }, {});
  }
github alex3165 / react-mapbox-gl / src / util / overlays.js View on Github external
if (!offset) {
    return normalizedOffsets(new Point(0, 0));
  }

  if (typeof offset === 'number') {
    // input specifies a radius from which to calculate offsets at all positions
    const cornerOffset = Math.round(Math.sqrt(0.5 * Math.pow(offset, 2)));
    return {
      center: new Point(offset, offset),
      top: new Point(0, offset),
      bottom: new Point(0, -offset),
      left: new Point(offset, 0),
      right: new Point(-offset, 0),
      'top-left': new Point(cornerOffset, cornerOffset),
      'top-right': new Point(-cornerOffset, cornerOffset),
      'bottom-left': new Point(cornerOffset, -cornerOffset),
      'bottom-right': new Point(-cornerOffset, -cornerOffset),
    };
  }

  if (isPointLike(offset)) {
    // input specifies a single offset to be applied to all positions
    return anchors.reduce((res, anchor) => {
      const tmp = Object.assign({}, res);
      tmp[anchor] = Point.convert(offset);
      return tmp;
    }, {});
  }

  // input specifies an offset per position
  return anchors.reduce((res, anchor) => {
    const tmp = Object.assign({}, res);
github alex3165 / react-mapbox-gl / src / util / overlays.js View on Github external
return normalizedOffsets(new Point(0, 0));
  }

  if (typeof offset === 'number') {
    // input specifies a radius from which to calculate offsets at all positions
    const cornerOffset = Math.round(Math.sqrt(0.5 * Math.pow(offset, 2)));
    return {
      center: new Point(offset, offset),
      top: new Point(0, offset),
      bottom: new Point(0, -offset),
      left: new Point(offset, 0),
      right: new Point(-offset, 0),
      'top-left': new Point(cornerOffset, cornerOffset),
      'top-right': new Point(-cornerOffset, cornerOffset),
      'bottom-left': new Point(cornerOffset, -cornerOffset),
      'bottom-right': new Point(-cornerOffset, -cornerOffset),
    };
  }

  if (isPointLike(offset)) {
    // input specifies a single offset to be applied to all positions
    return anchors.reduce((res, anchor) => {
      const tmp = Object.assign({}, res);
      tmp[anchor] = Point.convert(offset);
      return tmp;
    }, {});
  }

  // input specifies an offset per position
  return anchors.reduce((res, anchor) => {
    const tmp = Object.assign({}, res);
    tmp[anchor] = Point.convert(offset[anchor] || [0, 0]);
github alex3165 / react-mapbox-gl / src / util / overlays.js View on Github external
const normalizedOffsets = (offset) => {
  if (!offset) {
    return normalizedOffsets(new Point(0, 0));
  }

  if (typeof offset === 'number') {
    // input specifies a radius from which to calculate offsets at all positions
    const cornerOffset = Math.round(Math.sqrt(0.5 * Math.pow(offset, 2)));
    return {
      center: new Point(offset, offset),
      top: new Point(0, offset),
      bottom: new Point(0, -offset),
      left: new Point(offset, 0),
      right: new Point(-offset, 0),
      'top-left': new Point(cornerOffset, cornerOffset),
      'top-right': new Point(-cornerOffset, cornerOffset),
      'bottom-left': new Point(cornerOffset, -cornerOffset),
      'bottom-right': new Point(-cornerOffset, -cornerOffset),
    };
github alex3165 / react-mapbox-gl / src / util / overlays.js View on Github external
const normalizedOffsets = (offset) => {
  if (!offset) {
    return normalizedOffsets(new Point(0, 0));
  }

  if (typeof offset === 'number') {
    // input specifies a radius from which to calculate offsets at all positions
    const cornerOffset = Math.round(Math.sqrt(0.5 * Math.pow(offset, 2)));
    return {
      center: new Point(offset, offset),
      top: new Point(0, offset),
      bottom: new Point(0, -offset),
      left: new Point(offset, 0),
      right: new Point(-offset, 0),
      'top-left': new Point(cornerOffset, cornerOffset),
      'top-right': new Point(-cornerOffset, cornerOffset),
      'bottom-left': new Point(cornerOffset, -cornerOffset),
      'bottom-right': new Point(-cornerOffset, -cornerOffset),
    };
  }

  if (isPointLike(offset)) {
    // input specifies a single offset to be applied to all positions
    return anchors.reduce((res, anchor) => {
      const tmp = Object.assign({}, res);
      tmp[anchor] = Point.convert(offset);
      return tmp;