(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory();
	else if(typeof define === 'function' && define.amd)
		define("olInteractionMeasureTool", [], factory);
	else if(typeof exports === 'object')
		exports["olInteractionMeasureTool"] = factory();
	else
		root["olInteractionMeasureTool"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// identity function for calling harmony imports with the correct context
/******/ 	__webpack_require__.i = function(value) { return value; };
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, {
/******/ 				configurable: false,
/******/ 				enumerable: true,
/******/ 				get: getter
/******/ 			});
/******/ 		}
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "../";
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = 117);
/******/ })
/************************************************************************/
/******/ ({

/***/ 117:
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

var _factory = __webpack_require__(24);

var _factory2 = _interopRequireDefault(_factory);

var _layerUtils = __webpack_require__(17);

var _layerUtils2 = _interopRequireDefault(_layerUtils);

var _utils = __webpack_require__(12);

__webpack_require__(130);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

ol.interaction.MeasureTool = function (params) {
  this.options = params || {};

  this.wgs84Sphere = new ol.Sphere(typeof this.options['sphere'] === 'number' ? this.options['sphere'] : 6378137);

  this.measureTypes = {
    measureLength: {
      name: 'measureLength',
      type: 'LineString'
    },
    measureArea: {
      name: 'measureArea',
      type: 'Polygon'
    },
    measureCircle: {
      name: 'measureCircle',
      type: 'Circle'
    }
  };

  this.measureType = '';

  this.freehand = false;

  this.isGeodesic = this.options['isGeodesic'] === false ? this.options['isGeodesic'] : true;

  this.layerName = this.options['layerName'] || 'measureTool';

  this.layer = null;

  this.draw = null;

  this.isActive_ = false;

  this.clickCount = '';

  this.drawStyle = {
    fill: {
      fillColor: 'rgba(67, 110, 238, 0.4)'
    },
    stroke: {
      strokeColor: 'rgba(249, 185, 154, 1)',
      strokeWidth: 2.5
    },
    image: {
      type: '',
      image: {
        fill: {
          fillColor: 'rgba(255, 255, 255, 0.8)'
        },
        points: Infinity,
        radius: 4,
        stroke: {
          strokeColor: 'rgba(255, 0, 0, 1)',
          strokeWidth: 1.5
        }
      }
    }
  };
  if (this.options['drawStyle'] && _typeof(this.options['drawStyle']) === 'object') {
    this.drawStyle = this.options['drawStyle'];
  }

  this.finshStyle = {
    fill: {
      fillColor: 'rgba(67, 110, 238, 0.4)'
    },
    stroke: {
      strokeColor: 'rgba(253, 128, 68, 1)',
      strokeWidth: 3
    },
    image: {
      type: '',
      image: {
        fill: {
          fillColor: 'rgba(255, 255, 255, 0.8)'
        },
        points: Infinity,
        radius: 4,
        stroke: {
          strokeColor: 'rgba(255, 0, 0, 1)',
          strokeWidth: 1.5
        }
      }
    }
  };
  if (this.options['finshStyle'] && _typeof(this.options['finshStyle']) === 'object') {
    this.finshStyle = this.options['finshStyle'];
  }

  this.cursor_ = 'default';

  this.previousCursor_ = undefined;
  ol.interaction.Pointer.call(this, {
    handleMoveEvent: ol.interaction.MeasureTool.handleMoveEvent_,
    handleDownEvent: ol.interaction.MeasureTool.handleDownEvent_,
    handleDragEvent: ol.interaction.MeasureTool.handleDragEvent_
  });

  this.doubleClickZoom = null;
};

ol.inherits(ol.interaction.MeasureTool, ol.interaction.Pointer);

ol.interaction.MeasureTool.handleMoveEvent_ = function (mapBrowserEvent) {
  if (this.getTool()) {
    if (this.drawStart_ && !mapBrowserEvent.dragging && this.measureType === this.measureTypes.measureCircle['name']) {
      this.afterDrawPointClickHandler(mapBrowserEvent);
    } else if (!this.drawStart_ && !mapBrowserEvent.dragging) {
      this.beforeDrawPointClickHandler(mapBrowserEvent);
    } else if (this.drawStart_ && !mapBrowserEvent.dragging) {
      this.afterDrawPointClickHandler(mapBrowserEvent);
    } else if (this.freehand && this.drawStart_ && mapBrowserEvent.dragging) {
      this.afterDragHandler_(mapBrowserEvent);
    }
  }
};

ol.interaction.MeasureTool.handleDownEvent_ = function (mapBrowserEvent) {
  if (this.freehand) {
    console.log(mapBrowserEvent);
  }
};

ol.interaction.MeasureTool.handleDragEvent_ = function (mapBrowserEvent) {
  if (this.freehand) {
    console.log(mapBrowserEvent);
  }
};

ol.interaction.MeasureTool.prototype.addDrawInteractions_ = function (type) {
  var style_ = new _factory2.default(this.drawStyle);
  this.draw = new ol.interaction.Draw({
    type: type,
    style: style_,
    freehand: this.freehand
  });
  this.draw.set('uuid', (0, _utils.getuuid)());
  this.getMap().addInteraction(this.draw);
  this.draw.on('drawstart', this.drawStartHandle_, this);
  this.draw.on('drawend', this.drawEndHandle_, this);
  if (type === 'LineString' && !this.freehand) {
    this.getMap().on('singleclick', this.drawClickHandle_, this);
  }
};

ol.interaction.MeasureTool.prototype.drawClickHandle_ = function (event) {
  if (this.drawStart_ && !event.dragging) {
    if (!this.clickCount) {
      this.clickCount = (0, _utils.getuuid)();
      this.draw.set('measureResult', '起点');
    }
    this.addMeasurecircle(event.coordinate);
    this.addMeasureOverlay(event.coordinate, this.draw.get('measureResult'));
  }
};

ol.interaction.MeasureTool.prototype.addMeasurecircle = function (coordinate) {
  var feature = new ol.Feature({
    uuid: this.draw.get('uuid'),
    geometry: new ol.geom.Point(coordinate)
  });
  this.layer.getSource().addFeature(feature);
};

ol.interaction.MeasureTool.prototype.drawStartHandle_ = function (event) {
  var _this = this;

  var that = this;
  this.drawStart_ = true;
  event.feature.getGeometry().on('change', function (evt) {
    var geom = evt.target;
    if (geom instanceof ol.geom.LineString) {
      var output = that.formatData(geom);
      that.draw.set('measureResult', output);
    } else if (geom instanceof ol.geom.Polygon) {
      var area = _this.formatData(geom);
      that.draw.set('measureResult', area);
    } else if (geom instanceof ol.geom.Circle) {
      var _area = _this.formatData(geom);
      that.draw.set('measureResult', _area);
    }
  });
};

ol.interaction.MeasureTool.prototype.drawEndHandle_ = function (event) {
  this.drawEnd_ = true;
  var feature = event.feature;
  feature.set('uuid', this.draw.get('uuid'));
  this.layer.getSource().addFeature(feature);
  var coordinates = feature.getGeometry().getLastCoordinate();
  if (this.measureTypes.measureLength['name'] === this.measureType) {
    this.addMeasurecircle(coordinates);
    this.addMeasureOverlay(coordinates, this.draw.get('measureResult'), 'length');
  } else if (this.measureTypes.measureArea['name'] === this.measureType) {
    var center = ol.extent.getCenter(feature.getGeometry().getExtent());
    this.addMeasureOverlay(center, this.draw.get('measureResult'), 'area');
  } else if (this.measureTypes.measureCircle['name'] === this.measureType) {
    var _center = ol.extent.getCenter(feature.getGeometry().getExtent());
    this.addMeasureOverlay(_center, this.draw.get('measureResult'), 'circle');
  }
  this.addMeasureRemoveButton(coordinates);
  this.setTool(false);
  this.dispatchEvent('measureEnd');
};

ol.interaction.MeasureTool.prototype.beforeDrawPointClickHandler = function (event) {
  if (!this.measureHelpTooltip && this.getTool()) {
    var helpTooltipElement = document.createElement('span');
    if (this.measureTypes.measureLength['name'] === this.measureType) {
      helpTooltipElement.className = 'hamp-js-measure hamp-js-measure-length';
      if (this.freehand) {
        helpTooltipElement.innerHTML = '按下鼠标拖拽开始测量';
      } else {
        helpTooltipElement.innerHTML = '单击开始测距';
      }
    } else if (this.measureTypes.measureArea['name'] === this.measureType) {
      helpTooltipElement.className = 'hamp-js-measure hamp-js-measure-area';
      if (this.freehand) {
        helpTooltipElement.innerHTML = '按下鼠标拖拽开始测量';
      } else {
        helpTooltipElement.innerHTML = '单击开始测面';
      }
    } else if (this.measureTypes.measureCircle['name'] === this.measureType) {
      helpTooltipElement.className = 'hamp-js-measure hamp-js-measure-area';
      if (this.freehand) {
        helpTooltipElement.innerHTML = '按下鼠标拖拽开始测量';
      } else {
        helpTooltipElement.innerHTML = '单击开始测方圆面积';
      }
    }
    this.measureHelpTooltip = new ol.Overlay({
      element: helpTooltipElement,
      offset: [15, 0],
      positioning: 'center-left'
    });
    this.measureHelpTooltip.set('layerName', this.layerName);
    this.getMap().addOverlay(this.measureHelpTooltip);
  } else if (this.measureHelpTooltip && this.measureHelpTooltip instanceof ol.Overlay) {
    this.measureHelpTooltip.setPosition(event.coordinate);
  }
};

ol.interaction.MeasureTool.prototype.afterDrawPointClickHandler = function (event) {
  var helpTooltipElement = this.measureHelpTooltip.getElement();
  if (this.measureTypes.measureLength['name'] === this.measureType) {
    helpTooltipElement.className = 'hamp-js-measure-move hamp-js-measure-length';
    var length = this.draw.get('measureResult');
    helpTooltipElement.innerHTML = '<span>总长：' + '<span class="measure-result">' + length + '</span>' + '</span><br>' + '<span class="tool-tip">单击确定地点，双击结束</span>';
  } else if (this.measureTypes.measureArea['name'] === this.measureType) {
    helpTooltipElement.className = 'hamp-js-measure-move hamp-js-measure-area';
    var area = this.draw.get('measureResult');
    helpTooltipElement.innerHTML = '<span>总面积：' + '<span class="measure-result">' + area + '</span>' + '</span><br>' + '<span class="tool-tip">单击确定地点，双击结束</span>';
  } else if (this.measureTypes.measureCircle['name'] === this.measureType) {
    helpTooltipElement.className = 'hamp-js-measure-move hamp-js-measure-area';
    var _area2 = this.draw.get('measureResult');
    helpTooltipElement.innerHTML = '<span>总面积：' + '<span class="measure-result">' + _area2 + '</span>' + '</span><br>' + '<span class="tool-tip">单击确定地点，双击结束</span>';
  }
  this.measureHelpTooltip.setPosition(event.coordinate);
  this.getMap().render();
};

ol.interaction.MeasureTool.prototype.afterDragHandler_ = function (event) {
  var helpTooltipElement = this.measureHelpTooltip.getElement();
  if (this.measureTypes.measureLength['name'] === this.measureType) {
    helpTooltipElement.className = 'hamp-js-measure-move hamp-js-measure-length';
    var length = this.draw.get('measureResult');
    helpTooltipElement.innerHTML = '<span>总长：' + '<span class="measure-result">' + length + '</span>' + '</span><br>' + '<span class="tool-tip">松开鼠标按键结束测量</span>';
  } else if (this.measureTypes.measureArea['name'] === this.measureType) {
    helpTooltipElement.className = 'hamp-js-measure-move hamp-js-measure-area';
    var area = this.draw.get('measureResult');
    helpTooltipElement.innerHTML = '<span>总面积：' + '<span class="measure-result">' + area + '</span>' + '</span><br>' + '<span class="tool-tip">松开鼠标按键结束测量</span>';
  } else if (this.measureTypes.measureCircle['name'] === this.measureType) {
    helpTooltipElement.className = 'hamp-js-measure-move hamp-js-measure-area';
    var _area3 = this.draw.get('measureResult');
    helpTooltipElement.innerHTML = '<span>总面积：' + '<span class="measure-result">' + _area3 + '</span>' + '</span><br>' + '<span class="tool-tip">松开鼠标按键结束测量</span>';
  }
  this.measureHelpTooltip.setPosition(event.coordinate);
  this.getMap().render();
};

ol.interaction.MeasureTool.prototype.addMeasureOverlay = function (coordinate, length, type) {
  var measureResult = document.createElement('span');
  var measureOverlay = null;
  if (type === 'length') {
    measureResult.className = 'hmap-measure-end-overlay-label';
    measureResult.innerHTML = "总长：<span class='measure-end-label'>" + length + '</span>';
    measureOverlay = new ol.Overlay({
      element: measureResult,
      position: coordinate,
      offset: [10, 10],
      positioning: 'top-left'
    });
  } else if (type === 'area') {
    measureResult.className = 'hmap-measure-area-overlay-label';
    measureResult.innerHTML = '<span class="measure-label">' + length + '</span>';
    measureOverlay = new ol.Overlay({
      element: measureResult,
      position: coordinate,
      positioning: 'center-center'
    });
  } else if (type === 'circle') {
    measureResult.className = 'hmap-measure-area-overlay-label';
    measureResult.innerHTML = '<span class="measure-label">' + length + '</span>';
    measureOverlay = new ol.Overlay({
      element: measureResult,
      position: coordinate,
      positioning: 'center-center'
    });
  } else {
    measureResult.className = 'hmap-measure-overlay-label';
    measureResult.innerHTML = length;
    measureOverlay = new ol.Overlay({
      element: measureResult,
      position: coordinate,
      offset: [10, 0],
      positioning: 'center-left'
    });
  }
  measureOverlay.set('layerName', this.layerName);
  measureOverlay.set('uuid', this.draw.get('uuid'));
  this.getMap().addOverlay(measureOverlay);
  this.getMap().render();
};

ol.interaction.MeasureTool.prototype.addMeasureRemoveButton = function (coordinate) {
  var that = this;
  var imageButton = document.createElement('img');
  imageButton.src = this.options['removeButtonSrc'] ? this.options['removeButtonSrc'] : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NEYzMzc1RDY3RDU1MTFFNUFDNDJFNjQ4NUUwMzRDRDYiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NEYzMzc1RDc3RDU1MTFFNUFDNDJFNjQ4NUUwMzRDRDYiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo0RjMzNzVENDdENTUxMUU1QUM0MkU2NDg1RTAzNENENiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo0RjMzNzVENTdENTUxMUU1QUM0MkU2NDg1RTAzNENENiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PsDx84AAAAC3SURBVHjavJIxDoMwDEV/ok5wDCbu0DvAdUBIwMLFSs/AxDXY6tZ2SCGVUikd+ifn20+2k5hHVd0AXJGmGQw+UyWMxY8KQGpbUNcB23aYHIsnuSgIy8dlAQ2DgwWSmD0YE5ReAq5pQOMIrKsDRByjKGC/dsxz2L7XQgU8JB7n4qDoY6SYF4J+p72T7/zeOXqr03SMx8XnsTUX7UgElKVCyDK3s8Tsae6sv/8ceceZ6jr1k99fAgwAsZy0Sa2HgDcAAAAASUVORK5CYII=';
  imageButton.style.cursor = 'pointer';
  imageButton.title = '清除测量结果';
  imageButton.uuid_ = this.draw.get('uuid');
  imageButton.onclick = function (event) {
    that.removeMeasure_(this.uuid_);
  };
  var closeBtn = new ol.Overlay({
    element: imageButton,
    offset: [8, 0],
    position: coordinate,
    positioning: 'center-left'
  });
  closeBtn.set('uuid', this.draw.get('uuid'));
  closeBtn.set('layerName', this.layerName);
  this.getMap().addOverlay(closeBtn);
  this.getMap().render();
};

ol.interaction.MeasureTool.prototype.removeMeasure_ = function (uuid) {
  var overlays = this.getMap().getOverlays().getArray();
  if (overlays && Array.isArray(overlays)) {
    var length = overlays.length;

    for (var j = 0, i = 0; j < length; j++) {
      i++;
      if (overlays[length - i] && overlays[length - i] instanceof ol.Overlay && overlays[length - i].get('uuid') === uuid) {
        this.getMap().removeOverlay(overlays[length - i]);
      }
    }
  }
  if (this.layer && this.layer.getSource()) {
    var source = this.layer.getSource();
    var features = source.getFeatures();
    features.forEach(function (feat) {
      if (feat.get('uuid') === uuid) {
        source.removeFeature(feat);
      }
    }, this);
  }
};

ol.interaction.MeasureTool.prototype.setTool = function (active, key, freehand) {
  this.removeLastInteraction_();
  if (active && key && this.measureTypes.hasOwnProperty(key)) {
    this.isActive_ = active;
    this.freehand = freehand;
    this.measureType = key;
    if (!this.layer) {
      var _style = new _factory2.default(this.finshStyle);
      this.layer = new _layerUtils2.default(this.getMap()).createVectorLayer(this.layerName, {
        create: true
      });
      this.layer.setStyle(_style);
    }
    this.addDrawInteractions_(this.measureTypes[key]['type']);
  }
};

ol.interaction.MeasureTool.prototype.removeLastInteraction_ = function () {
  this.isActive_ = false;
  this.freehand = false;
  this.drawStart_ = false;
  if (this.draw) {
    this.draw.un('drawstart', this.drawStartHandle_, this);
    this.draw.un('drawend', this.drawEndHandle_, this);
    this.getMap().un('singleclick', this.drawClickHandle_, this);
    if (this.measureHelpTooltip && this.measureHelpTooltip instanceof ol.Overlay) {
      this.getMap().removeOverlay(this.measureHelpTooltip);
      this.measureHelpTooltip = null;
    }
    this.clickCount = '';
    this.disActionInteraction();
    this.getMap().removeInteraction(this.draw);
    this.measureType = '';
  }
};

ol.interaction.MeasureTool.prototype.getTool = function () {
  return this.isActive_;
};

ol.interaction.MeasureTool.prototype.setActive = function (active) {
  ol.interaction.Pointer.prototype.setActive.call(this, active);
};

ol.interaction.MeasureTool.prototype.disActionInteraction = function () {
  var _this2 = this;

  this.doubleClickZoom = this.getDoubleClickZoomInteraction();
  var active = this.doubleClickZoom.getActive();
  this.doubleClickZoom.setActive(false);
  window.setTimeout(function () {
    _this2.doubleClickZoom.setActive(active);
  }, 200);
};

ol.interaction.MeasureTool.prototype.getDoubleClickZoomInteraction = function () {
  var _this3 = this;

  if (!this.doubleClickZoom) {
    var items = this.getMap().getInteractions().getArray();
    items.every(function (item) {
      if (item && item instanceof ol.interaction.DoubleClickZoom) {
        _this3.doubleClickZoom = item;
        return false;
      } else {
        return true;
      }
    });
  }
  return this.doubleClickZoom;
};

ol.interaction.MeasureTool.prototype.formatData = function (geom) {
  var output = 0;
  if (geom) {
    if (this.measureTypes.measureLength['name'] === this.measureType) {
      if (this.isGeodesic) {
        var _ref = [geom.getCoordinates(), 0],
            coordinates = _ref[0],
            length = _ref[1];

        var sourceProj = this.getMap().getView().getProjection();
        for (var i = 0, ii = coordinates.length - 1; i < ii; ++i) {
          var c1 = ol.proj.transform(coordinates[i], sourceProj, 'EPSG:4326');
          var c2 = ol.proj.transform(coordinates[i + 1], sourceProj, 'EPSG:4326');
          length += this.wgs84Sphere.haversineDistance(c1, c2);
        }
        if (length > 100) {
          output = Math.round(length / 1000 * 100) / 100 + ' ' + '公里';
        } else {
          output = Math.round(length * 100) / 100 + ' ' + '米';
        }
      } else {
        output = Math.round(geom.getLength() * 100) / 100;
      }
    } else if (this.measureType === 'measureArea') {
      if (this.isGeodesic) {
        var _sourceProj = this.getMap().getView().getProjection();
        var geometry = geom.clone().transform(_sourceProj, 'EPSG:4326');
        var _coordinates = geometry.getLinearRing(0).getCoordinates();
        var area = Math.abs(this.wgs84Sphere.geodesicArea(_coordinates));
        if (area > 10000000000) {
          output = Math.round(area / (1000 * 1000 * 10000) * 100) / 100 + ' ' + '万平方公里';
        } else if (area > 1000000 && area < 10000000000) {
          output = Math.round(area / (1000 * 1000) * 100) / 100 + ' ' + '平方公里';
        } else {
          output = Math.round(area * 100) / 100 + ' ' + '平方米';
        }
      } else {
        output = geom.getArea();
      }
    } else if (this.measureType === 'measureCircle') {
      var _sourceProj2 = this.getMap().getView().getProjection();
      var circle = geom.clone().transform(_sourceProj2, 'EPSG:4326');
      var polygon = ol.geom.Polygon.fromCircle(circle, 64, 0);
      if (this.isGeodesic) {
        var _coordinates2 = polygon.getLinearRing(0).getCoordinates();
        var _area4 = Math.abs(this.wgs84Sphere.geodesicArea(_coordinates2));
        if (_area4 > 10000000000) {
          output = Math.round(_area4 / (1000 * 1000 * 10000) * 100) / 100 + ' ' + '万平方公里';
        } else if (_area4 > 1000000 && _area4 < 10000000000) {
          output = Math.round(_area4 / (1000 * 1000) * 100) / 100 + ' ' + '平方公里';
        } else {
          output = Math.round(_area4 * 100) / 100 + ' ' + '平方米';
        }
      } else {
        output = polygon.getArea();
      }
    }
  }
  return output;
};

var olInteractionMeasureTool = ol.interaction.MeasureTool;
exports.default = olInteractionMeasureTool;
module.exports = exports['default'];

/***/ }),

/***/ 12:
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

var has = function has(object_, key_) {
  return (typeof object_ === 'undefined' ? 'undefined' : _typeof(object_)) === 'object' && object_.hasOwnProperty(key_);
};

var checkBrowser = function checkBrowser() {
  var userAgent = navigator.userAgent;
  if (userAgent.indexOf('OPR') > -1) {
    return 'Opera';
  } else if (userAgent.indexOf('Firefox') > -1) {
    return 'FF';
  } else if (userAgent.indexOf('Trident') > -1) {
    return 'IE';
  } else if (userAgent.indexOf('Edge') > -1) {
    return 'Edge';
  } else if (userAgent.indexOf('Chrome') > -1) {
    return 'Chrome';
  } else if (userAgent.indexOf('Safari') > -1) {
    return 'Safari';
  }
};

var getuuid = function getuuid() {
  var s = [],
      hexDigits = '0123456789abcdef';

  for (var i = 0; i < 36; i++) {
    s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
  }
  s[14] = '4';
  s[19] = hexDigits.substr(s[19] & 0x3 | 0x8, 1);
  s[8] = s[13] = s[18] = s[23] = '-';
  return s.join('');
};

exports.has = has;
exports.checkBrowser = checkBrowser;
exports.getuuid = getuuid;

/***/ }),

/***/ 130:
/***/ (function(module, exports) {

// removed by extract-text-webpack-plugin

/***/ }),

/***/ 17:
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});
ol.layer.LayerUtils = function (map) {
  if (map && map instanceof ol.Map) {
    this.map = map;
  } else {
    throw new Error('传入的不是地图对象！');
  }
};

ol.layer.LayerUtils.prototype.getLayerByLayerName = function (layerName) {
  try {
    var targetLayer = null;
    if (this.map) {
      var layers = this.map.getLayers().getArray();
      targetLayer = this.getLayerInternal(layers, 'layerName', layerName);
    }
    return targetLayer;
  } catch (e) {
    console.log(e);
  }
};

ol.layer.LayerUtils.prototype.getLayerInternal = function (layers, key, value) {
  var _this = this;

  var _target = null;
  if (layers.length > 0) {
    layers.every(function (layer) {
      if (layer instanceof ol.layer.Group) {
        var _layers = layer.getLayers().getArray();
        _target = _this.getLayerInternal(_layers, key, value);
        if (_target) {
          return false;
        } else {
          return true;
        }
      } else if (layer.get(key) === value) {
        _target = layer;
        return false;
      } else {
        return true;
      }
    });
  }
  return _target;
};

ol.layer.LayerUtils.prototype.getLayersArrayInternal = function (layers, key, value) {
  var _this2 = this;

  var _target = [];
  if (layers.length > 0) {
    layers.forEach(function (layer) {
      if (layer instanceof ol.layer.Group) {
        var _layers2 = layer.getLayers().getArray();
        _target = _this2.getLayerInternal(_layers2, key, value);
        if (_target) {
          _target.push(layer);
        }
      } else if (layer.get(key) === value) {
        _target.push(layer);
      }
    });
  }
  return _target;
};

ol.layer.LayerUtils.prototype.getLayerByKeyValue = function (key, value) {
  try {
    var targetLayer = null;
    if (this.map) {
      var layers = this.map.getLayers().getArray();
      targetLayer = this.getLayerInternal(layers, key, value);
    }
    return targetLayer;
  } catch (e) {
    console.log(e);
  }
};

ol.layer.LayerUtils.prototype.getLayersArrayByKeyValue = function (key, value) {
  try {
    var targetLayers = [];
    if (this.map) {
      var layers = this.map.getLayers().getArray();
      targetLayers = this.getLayersArrayInternal(layers, key, value);
    }
    return targetLayers;
  } catch (e) {
    console.log(e);
  }
};

ol.layer.LayerUtils.prototype.createVectorLayer = function (layerName, params) {
  try {
    if (this.map) {
      var vectorLayer = this.getLayerByLayerName(layerName);
      if (!(vectorLayer instanceof ol.layer.Vector)) {
        vectorLayer = null;
      }
      if (!vectorLayer) {
        if (params && params.create) {
          vectorLayer = new ol.layer.Vector({
            layerName: layerName,
            params: params,
            layerType: 'vector',
            source: new ol.source.Vector({
              wrapX: false
            }),
            style: new ol.style.Style({
              fill: new ol.style.Fill({
                color: 'rgba(67, 110, 238, 0.4)'
              }),
              stroke: new ol.style.Stroke({
                color: '#4781d9',
                width: 2
              }),
              image: new ol.style.Circle({
                radius: 7,
                fill: new ol.style.Fill({
                  color: '#ffcc33'
                })
              })
            })
          });
        }
      }
      if (this.map && vectorLayer) {
        if (params && params.hasOwnProperty('selectable')) {
          vectorLayer.set('selectable', params.selectable);
        }

        var _vectorLayer = this.getLayerByLayerName(layerName);
        if (!_vectorLayer || !(_vectorLayer instanceof ol.layer.Vector)) {
          this.map.addLayer(vectorLayer);
        }
      }
      return vectorLayer;
    }
  } catch (e) {
    console.log(e);
  }
};

var olLayerLayerUtils = ol.layer.LayerUtils;
exports.default = olLayerLayerUtils;
module.exports = exports['default'];

/***/ }),

/***/ 24:
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

ol.style.Factory = function (options) {
  var option = options && (typeof options === 'undefined' ? 'undefined' : _typeof(options)) === 'object' ? options : {};
  var style = new ol.style.Style({});
  if (option['geometry'] && option['geometry'] instanceof ol.geom.Geometry) {
    style.setGeometry(option['geometry']);
  }
  if (option['zIndex'] && typeof option['zIndex'] === 'number') {
    style.setZIndex(option['zIndex']);
  }
  if (option['fill'] && _typeof(option['fill']) === 'object') {
    style.setFill(this._getFill(option['fill']));
  }
  if (option['image'] && _typeof(option['image']) === 'object') {
    style.setImage(this._getImage(option['image']));
  }
  if (option['stroke'] && _typeof(option['stroke']) === 'object') {
    style.setStroke(this._getStroke(option['stroke']));
  }
  if (option['text'] && _typeof(option['text']) === 'object') {
    style.setText(this._getText(option['text']));
  }
  return style;
};

ol.style.Factory.prototype._getRegularShape = function (options) {
  try {
    var regularShape = new ol.style.RegularShape({
      fill: this._getFill(options['fill']) || undefined,
      points: typeof options['points'] === 'number' ? options['points'] : 1,
      radius: typeof options['radius'] === 'number' ? options['radius'] : undefined,
      radius1: typeof options['radius1'] === 'number' ? options['radius1'] : undefined,
      radius2: typeof options['radius2'] === 'number' ? options['radius2'] : undefined,
      angle: typeof options['angle'] === 'number' ? options['angle'] : 0,
      snapToPixel: typeof options['snapToPixel'] === 'boolean' ? options['snapToPixel'] : true,
      stroke: this._getStroke(options['stroke']) || undefined,
      rotation: typeof options['rotation'] === 'number' ? options['rotation'] : 0,
      rotateWithView: typeof options['rotateWithView'] === 'boolean' ? options['rotateWithView'] : false,
      atlasManager: options['atlasManager'] ? options['atlasManager'] : undefined
    });
    return regularShape;
  } catch (e) {
    console.log(e);
  }
};

ol.style.Factory.prototype._getImage = function (options) {
  try {
    var image = void 0;
    options = options || {};
    if (options['type'] === 'icon') {
      image = this._getIcon(options['image']);
    } else {
      image = this._getRegularShape(options['image']);
    }
    return image;
  } catch (e) {
    console.log(e);
  }
};

ol.style.Factory.prototype._getIcon = function (options) {
  try {
    options = options || {};
    var icon = new ol.style.Icon({
      anchor: options['imageAnchor'] ? options['imageAnchor'] : [0.5, 0.5],
      anchorXUnits: options['imageAnchorXUnits'] ? options['imageAnchorXUnits'] : 'fraction',
      anchorYUnits: options['imageAnchorYUnits'] ? options['imageAnchorYUnits'] : 'fraction',
      anchorOrigin: options['imageAnchorOrigin'] ? options['imageAnchorYUnits'] : 'top-left',
      color: options['imageColor'] ? options['imageColor'] : undefined,
      crossOrigin: options['crossOrigin'] ? options['crossOrigin'] : undefined,
      img: options['img'] ? options['img'] : undefined,
      offset: options['offset'] && Array.isArray(options['offset']) && options['offset'].length === 2 ? options['offset'] : [0, 0],
      offsetOrigin: options['offsetOrigin'] ? options['offsetOrigin'] : 'top-left',
      scale: typeof options['scale'] === 'number' ? options['scale'] : 1,
      snapToPixel: typeof options['snapToPixel'] === 'boolean' ? options['snapToPixel'] : true,
      rotateWithView: typeof options['rotateWithView'] === 'boolean' ? options['rotateWithView'] : false,
      opacity: typeof options['imageOpacity'] === 'number' ? options['imageOpacity'] : 1,
      rotation: typeof options['imageRotation'] === 'number' ? options['imageRotation'] : 0,
      size: options['size'] && Array.isArray(options['size']) && options['size'].length === 2 ? options['size'] : undefined,
      imgSize: options['imgSize'] && Array.isArray(options['imgSize']) && options['imgSize'].length === 2 ? options['imgSize'] : undefined,
      src: options['imageSrc'] ? options['imageSrc'] : undefined
    });
    return icon;
  } catch (error) {
    console.log(error);
  }
};

ol.style.Factory.prototype._getStroke = function (options) {
  try {
    options = options || {};
    var stroke = new ol.style.Stroke({
      color: options['strokeColor'] ? options['strokeColor'] : undefined,
      lineCap: options['strokeLineCap'] && typeof options['strokeLineCap'] === 'string' ? options['strokeLineCap'] : 'round',
      lineJoin: options['strokeLineJoin'] && typeof options['strokeLineJoin'] === 'string' ? options['strokeLineJoin'] : 'round',
      lineDash: options['strokeLineDash'] ? options['strokeLineDash'] : undefined,
      lineDashOffset: typeof options['strokeLineDashOffset'] === 'number' ? options['strokeLineDashOffset'] : '0',
      miterLimit: typeof options['strokeMiterLimit'] === 'number' ? options['strokeMiterLimit'] : 10,
      width: typeof options['strokeWidth'] === 'number' ? options['strokeWidth'] : undefined
    });
    return stroke;
  } catch (error) {
    console.log(error);
  }
};

ol.style.Factory.prototype._getText = function (options) {
  try {
    var text = new ol.style.Text({
      font: options['textFont'] && typeof options['textFont'] === 'string' ? options['textFont'] : '10px sans-serif',
      offsetX: typeof options['textOffsetX'] === 'number' ? options['textOffsetX'] : 0,
      offsetY: typeof options['textOffsetY'] === 'number' ? options['textOffsetY'] : 0,
      scale: typeof options['textScale'] === 'number' ? options['textScale'] : undefined,
      rotation: typeof options['textRotation'] === 'number' ? options['textRotation'] : 0,
      text: options['text'] && typeof options['text'] === 'string' ? options['text'] : undefined,
      textAlign: options['textAlign'] && typeof options['textAlign'] === 'string' ? options['textAlign'] : 'start',
      textBaseline: options['textBaseline'] && typeof options['textBaseline'] === 'string' ? options['textBaseline'] : 'alphabetic',
      rotateWithView: typeof options['rotateWithView'] === 'boolean' ? options['rotateWithView'] : false,
      fill: this._getFill(options['textFill']),
      stroke: this._getStroke(options['textStroke'])
    });
    return text;
  } catch (error) {
    console.log(error);
  }
};

ol.style.Factory.prototype._getFill = function (options) {
  try {
    options = options || {};
    var fill = new ol.style.Fill({
      color: options['fillColor'] ? options['fillColor'] : undefined
    });
    return fill;
  } catch (error) {
    console.log(error);
  }
};

var olStyleFactory = ol.style.Factory;
exports.default = olStyleFactory;
module.exports = exports['default'];

/***/ })

/******/ });
});
//# sourceMappingURL=olInteractionMeasureTool.js.map