(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory();
	else if(typeof define === 'function' && define.amd)
		define("olLayerUtils", [], factory);
	else if(typeof exports === 'object')
		exports["olLayerUtils"] = factory();
	else
		root["olLayerUtils"] = 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 = 17);
/******/ })
/************************************************************************/
/******/ ({

/***/ 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'];

/***/ })

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