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

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

"use strict";


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

ol.source.BAIDU = function (optOptions) {
  var options = optOptions || {};
  var attributions = '';
  if (options.attributions !== undefined) {
    attributions = options.attributions;
  } else {
    attributions = [ol.source.BAIDU.ATTRIBUTION];
  }
  options.projection = options['projection'] ? options.projection : 'EPSG:3857';
  var crossOrigin = options.crossOrigin !== undefined ? options.crossOrigin : 'anonymous';
  var url = options.url !== undefined ? options.url : 'http://online{0-3}.map.bdimg.com/onlinelabel/?qt=tile&x={x}&y={y}&z={z}&styles=pl&udt=20170607&scaler=1&p=1';
  var tileUrlFunction = options.tileUrlFunction ? options.tileUrlFunction : undefined;
  if (!tileUrlFunction) {
    tileUrlFunction = function tileUrlFunction(tileCoord) {
      var z = tileCoord[0];
      var x = tileCoord[1];
      var y = tileCoord[2];
      if (x < 0) {
        x = 'M' + -x;
      }
      if (y < 0) {
        y = 'M' + -y;
      }
      return url.replace('{0-3}', ol.source.BAIDU.getRandom(0, 3)).replace('{x}', x.toString()).replace('{y}', y.toString()).replace('{z}', z.toString());
    };
  }
  var levels = options['levels'] ? options['levels'] : 19;
  var resolutions = [];
  for (var z = 0; z < levels; z++) {
    resolutions[z] = Math.pow(2, levels - 1 - z);
  }
  var tileGrid = new ol.tilegrid.TileGrid({
    tileSize: options['tileSize'] ? options['tileSize'] : 256,
    origin: options['origin'] ? options['origin'] : [0, 0],
    extent: options['extent'] ? options['extent'] : undefined,
    resolutions: resolutions,
    minZoom: options['minZoom'] && typeof options['minZoom'] === 'number' ? options['minZoom'] : 0
  });
  ol.source.TileImage.call(this, {
    tileGrid: tileGrid,
    attributions: attributions,
    cacheSize: options.cacheSize,
    projection: options.projection,
    crossOrigin: crossOrigin,
    opaque: options.opaque !== undefined ? options.opaque : true,
    maxZoom: options.maxZoom !== undefined ? options.maxZoom : 19,
    reprojectionErrorThreshold: options.reprojectionErrorThreshold,
    tileUrlFunction: tileUrlFunction,
    url: url,
    wrapX: options.wrapX
  });
};
ol.inherits(ol.source.BAIDU, ol.source.TileImage);

ol.source.BAIDU.getRandom = function (min, max) {
  var r = Math.random() * (max - min);
  var re = Math.round(r + min);
  re = Math.max(Math.min(re, max), min);
  return re;
};

ol.source.BAIDU.ATTRIBUTION = new ol.Attribution({
  html: '&copy; ' + '<a href="http://map.baidu.com/">百度地图</a> ' + 'contributors.'
});

var olSourceBaidu = ol.source.BAIDU;
exports.default = olSourceBaidu;
module.exports = exports['default'];

/***/ })

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