/*!
*
* iclient9-mapboxgl.(http://iclient.supermap.io)
* Copyright© 2000-2017 SuperMap Software Co. Ltd
* license: Apache-2.0
* version: v9.0.0
*
*/
/******/ (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 = 9);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {
module.exports = mapboxgl;
/***/ }),
/* 1 */
/***/ (function(module, exports) {
module.exports = function(){try{return mapv}catch(e){return {}}}();
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Logo = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _mapboxGl = __webpack_require__(0);
var _mapboxGl2 = _interopRequireDefault(_mapboxGl);
var _iClient = __webpack_require__(8);
var _iClient2 = _interopRequireDefault(_iClient);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* @class mapboxgl.supermap.LogoControl
* @classdesc Logo控件。默认不显示
*
* @example
* (start code)
* map.addControl(new mapboxgl.supermap.LogoControl(),'bottom-right');
* (end)
* @param options -{Object} logo控件配置项
* imageUrl - {string} logo图片地址
* width - {string} logo图片宽
* height - {string} logo图片高
* link - {string} 跳转链接
* alt - {string} logo图片失效时显示文本
*/
var Logo = exports.Logo = function () {
//logo图片高
//跳转链接
function Logo(options) {
_classCallCheck(this, Logo);
this.imageUrl = null;
this.link = null;
this.width = null;
this.height = null;
this.alt = "SuperMap iClient";
this._extend(this, options);
}
/**
* @function mapboxgl.supermap.LogoControl.prototype.onAdd
* @description 添加一个logo
* @return {div} 返回创建的logo元素
*/
//logo图片失效时显示文本
//logo图片宽
//logo图片地址
_createClass(Logo, [{
key: 'onAdd',
value: function onAdd(map) {
this._map = map;
this._container = document.createElement('div');
this._container.className = 'mapboxgl-ctrl iclient-logo';
this._container.style.marginTop = 0;
this._container.style.marginBottom = 0;
this._container.style.marginLeft = 0;
this._container.style.marginRight = 0;
var imgSrc = _iClient2.default;
if (this.imageUrl) {
imgSrc = this.imageUrl;
}
var alt = this.alt;
var imageWidth = "94px";
var imageHeight = "29px";
var styleSize = "width:" + imageWidth + ";height:" + imageHeight + ";";
if (this.imageUrl) {
imageWidth = this.width;
imageHeight = this.height;
styleSize = "width:" + imageWidth + ";height:" + imageHeight + ";";
if (!imageWidth || !imageHeight) {
styleSize = "";
}
}
var link = this.link || "http://iclient.supermap.io";
this._container.innerHTML = "" + "";
this._createStyleSheet();
return this._container;
}
}, {
key: '_createStyleSheet',
value: function _createStyleSheet() {
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = ".iclient-logo{" + "margin:0 !important;" + "}" + ".iclient-logo a{" + "border: none;" + "display: block;" + "height:31px;" + "}" + ".iclient-logo img{" + "border: none;" + "white-space: nowrap" + "}";
document.getElementsByTagName('head')[0].appendChild(style);
}
}, {
key: '_extend',
value: function _extend(dest) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = arguments[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var src = _step.value;
for (var k in src) {
dest[k] = src[k];
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return dest;
}
}]);
return Logo;
}();
_mapboxGl2.default.supermap = _mapboxGl2.default.supermap || {};
_mapboxGl2.default.supermap.LogoControl = Logo;
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.MapvLayer = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _MapvRenderer = __webpack_require__(7);
var _MapvRenderer2 = _interopRequireDefault(_MapvRenderer);
var _mapboxGl = __webpack_require__(0);
var _mapboxGl2 = _interopRequireDefault(_mapboxGl);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* @class mapboxgl.supermap.MapvLayer
* @classdesc Mapv图层
* @param map - {Object} 地图
* @param dataSet -{Object} 数据集
* @param mapVOptions -{Object} Mapv参数
*/
var MapvLayer = exports.MapvLayer = function () {
function MapvLayer(map, dataSet, mapVOptions) {
_classCallCheck(this, MapvLayer);
this.map = map;
this.renderer = new _MapvRenderer2.default(map, this, dataSet, mapVOptions);
this.canvas = this._createCanvas();
this.renderer._canvasUpdate();
this.mapContainer = map.getCanvasContainer();
this.mapContainer.appendChild(this.canvas);
}
/**
* @function mapboxgl.supermap.MapvLayer.prototype.getTopLeft
* @description 获取左上的距离
*/
_createClass(MapvLayer, [{
key: 'getTopLeft',
value: function getTopLeft() {
var map = this.map;
var topLeft;
if (map) {
var bounds = map.getBounds();
topLeft = bounds.getNorthWest();
}
return topLeft;
}
}, {
key: 'show',
value: function show() {
if (this.renderer) {
this.renderer._show();
}
return this;
}
}, {
key: 'hide',
value: function hide() {
if (this.renderer) {
this.renderer._hide();
}
return this;
}
}, {
key: '_createCanvas',
value: function _createCanvas() {
var canvas = document.createElement('canvas');
canvas.style.position = 'absolute';
canvas.style.top = 0 + "px";
canvas.style.left = 0 + "px";
canvas.width = parseInt(this.map.getCanvas().style.width);
canvas.height = parseInt(this.map.getCanvas().style.height);
canvas.style.width = this.map.getCanvas().style.width;
canvas.style.height = this.map.getCanvas().style.height;
return canvas;
}
}]);
return MapvLayer;
}();
_mapboxGl2.default.supermap = _mapboxGl2.default.supermap || {};
_mapboxGl2.default.supermap.MapvLayer = MapvLayer;
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.RankTheme3DLayer = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _mapboxGl = __webpack_require__(0);
var _mapboxGl2 = _interopRequireDefault(_mapboxGl);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* @class mapboxgl.supermap.RankTheme3DLayer
* @classdesc mapbox gl分段专题图
* @param id -{string} 专题图图层id
* @param map -{object} mapbox gl地图对象
* @param layerOptions -{Object} 专题图图层配置项
* opacity -{number} 图层透明度,默认1
* parseNumber -{boolean} 是否预处理数据,将数据转换为number,默认false
* baseHeightField -{string} 数据中表示基础高度的字段
* heightField -{string} 数据中表示高度的字段
* heightStops -{Array} 数据高度分段数组
* colorField -{string} 数据中表示颜色的字段
* colorStops -{Array} 数据颜色分段数组
* base -{number} 数据分段线性增量
* showLegend -{boolean} 是否显示图例,默认显示
* legendTitle -{string} 图例标题
* legendTheme -{string} 图例主题,取值:'light','dark'
* legendRatio -{number} 图例数值扩大系数,
* legendPosition -{string} 图例位置,取值:'top-right'|'top-left'|'bottom-left'|'bottom-right'
*/
var RankTheme3DLayer = exports.RankTheme3DLayer = function () {
/**
* @member mapboxgl.supermap.RankTheme3DLayer.prototype.legendTheme -{string}
* @description 图例主题,取值:'light','dark'
* @default 'light'
*/
/**
* @member mapboxgl.supermap.RankTheme3DLayer.prototype.legendTitle -{string}
* @description 图例标题
*/
/**
* @member mapboxgl.supermap.RankTheme3DLayer.prototype.base -{number}
* @description 数据分段线性增量
*/
/**
* @member mapboxgl.supermap.RankTheme3DLayer.prototype.colorField -{string}
* @description 数据中表示颜色的字段
*/
/**
* @member mapboxgl.supermap.RankTheme3DLayer.prototype.heightField -{string}
* @description 数据中表示高度的字段
*/
/**
* @member mapboxgl.supermap.RankTheme3DLayer.prototype.parseNumber -{boolean}
* @description 是否进行数据预处理,有些字段是string类型,需要转换为number
*/
/**
* @member mapboxgl.supermap.RankTheme3DLayer.prototype.map -{object}
* @description mapbox gl地图对象
*/
function RankTheme3DLayer(id, map, layerOptions) {
_classCallCheck(this, RankTheme3DLayer);
this.id = null;
this.map = null;
this.opacity = 1;
this.parseNumber = false;
this.baseHeightField = null;
this.heightField = null;
this.heightStops = null;
this.colorField = null;
this.colorStops = null;
this.base = null;
this.showLegend = true;
this.legendTitle = null;
this.legendRatio = 1;
this.legendTheme = 'light';
this.legendPosition = 'bottom-right';
this.id = id;
this.map = map;
this._extend(this, layerOptions);
this.heightField = layerOptions.heightField || 'height';
this.colorField = layerOptions.colorField || this.heightField;
}
/**
* @function mapboxgl.supermap.RankTheme3DLayer.prototype.setLayerOptions
* @description 设置图层相关参数
* @param layerOptions -{object} 该专题图图层相关参数
* * opacity -{number} 图层透明度,默认1
* parseNumber -{boolean} 是否预处理数据,将数据转换为number,默认false
* baseHeightField -{string} 数据中表示基础高度的字段
* heightField -{string} 数据中表示高度的字段
* heightStops -{Array} 数据高度分段数组
* colorField -{string} 数据中表示颜色的字段
* colorStops -{Array} 数据颜色分段数组
* base -{number} 数据分段线性增量
* showLegend -{boolean} 是否显示图例,默认显示
* legendTitle -{string} 图例标题
* legendRatio -{number} 图例数值扩大系数,
* legendTheme -{string} 图例主题,取值:'light','dark'
* legendPosition -{string} 图例位置,取值:'top-right'|'top-left'|'bottom-left'|'bottom-right'
* @returns {mapboxgl.supermap.RankTheme3DLayer}
*/
/**
* @member mapboxgl.supermap.RankTheme3DLayer.prototype.legendPosition -{string}
* @description 图例位置,取值:'top-right'|'top-left'|'bottom-left'|'bottom-right'
* @default 'bottom-right'
*/
/**
* @member mapboxgl.supermap.RankTheme3DLayer.prototype.legendRatio -{number}
* @description 图例数值扩大系数
*/
/**
* @member mapboxgl.supermap.RankTheme3DLayer.prototype.showLegend -{Boolean}
* @description 是否显示图例
*/
/**
* @member mapboxgl.supermap.RankTheme3DLayer.prototype.colorStops -{Array}
* @description 数据颜色分段数组
*/
/**
* @member mapboxgl.supermap.RankTheme3DLayer.prototype.heightStops -{Array}
* @description 数据高度分段数组
*/
/**
* @member mapboxgl.supermap.RankTheme3DLayer.prototype.baseHeightField -{string}
* @description 数据中表示基础高度的字段
*/
/**
* @member mapboxgl.supermap.RankTheme3DLayer.prototype.opacity -{number}
* @description 图层透明度,默认1
*/
/**
* @member mapboxgl.supermap.RankTheme3DLayer.prototype.id -{string}
* @description mapbox gl图层id
*/
_createClass(RankTheme3DLayer, [{
key: 'setLayerOptions',
value: function setLayerOptions(layerOptions) {
this._extend(this, layerOptions);
return this;
}
/**
* @function mapboxgl.supermap.RankTheme3DLayer.prototype.setData
* @description 设置数据,数据格式必须为geojson格式
* @param data -{object} geojson格式数据
* @param parseNumber -{object} 是否进行数据预处理,有些字段是string类型,需要转换为number
*/
}, {
key: 'setData',
value: function setData(data, parseNumber) {
var me = this;
me.data = data;
if (parseNumber != null) {
me.parseNumber = parseNumber;
}
me.parseNumber && me.data && me.data.features && me.data.features.map(function (val, index) {
if (me.baseHeightField && val.properties[me.baseHeightField]) {
val.properties[baseHeightField] = parseFloat(val.properties[baseHeightField]);
}
if (me.heightField && val.properties[me.heightField]) {
val.properties[me.heightField] = parseFloat(val.properties[me.heightField]);
}
});
return this;
}
/**
* @function mapboxgl.supermap.RankTheme3DLayer.prototype.getData
* @description 获取数据,返回的数据格式为geojson
* @returns {Object}
*/
}, {
key: 'getData',
value: function getData() {
return this.data;
}
/**
* @function mapboxgl.supermap.RankTheme3DLayer.prototype.show
* @description 显示图层
* @param options -{object} 图层相关参数,如图例标题和主题等
* @returns {mapboxgl.supermap.RankTheme3DLayer}
*/
}, {
key: 'show',
value: function show(options) {
this._addLayer();
this._extend(this, options);
if (this.showLegend) {
if (this.legend) {
map.addControl(legend, this.legendPosition);
} else {
var defaultLegend = this._createLegendControl();
this.map.addControl(defaultLegend, this.legendPosition);
}
}
return this;
}
}, {
key: '_createLegendControl',
value: function _createLegendControl(html) {
var me = this;
function LegendControl() {}
LegendControl.prototype.onAdd = function (map) {
this._map = map;
this._container = document.createElement('div');
var className = 'mapboxgl-ctrl legend ';
var theme = 'legend-light';
if (me.legendTheme === 'dark') {
theme = 'legend-dark';
}
this._container.className = className + theme;
if (html) {
this._container.innerHTML = html;
} else {
this._container.innerHTML = me._createLegendElement.call(me);
}
me._appendLegendCSSStyle();
return this._container;
};
LegendControl.prototype.onRemove = function () {
this._container.parentNode.removeChild(this._container);
this._map = undefined;
};
return new LegendControl();
}
}, {
key: '_createLegendElement',
value: function _createLegendElement() {
var len = this.colorStops && this.colorStops.length || 0;
var titleWidth = len * 60;
//图例标题
var titleElement = "";
var legendTitle = this.legendTitle || "";
titleElement = "
" + legendTitle + "
"; //颜色分段对应标识 var colorGalleryElement = "