From e537540f9f537dd167938e70f047310dce20d8f3 Mon Sep 17 00:00:00 2001 From: "Howard.Zuo" Date: Mon, 2 Apr 2018 11:52:41 +0800 Subject: [PATCH] Finish: upgrade version to 3.3.0 --- dist/angular-baidu-map.js | 937 ++++++++++++++++++++++++---------- dist/angular-baidu-map.min.js | 2 +- package.json | 2 +- 3 files changed, 660 insertions(+), 281 deletions(-) diff --git a/dist/angular-baidu-map.js b/dist/angular-baidu-map.js index 1eb8636..d87af04 100644 --- a/dist/angular-baidu-map.js +++ b/dist/angular-baidu-map.js @@ -125,43 +125,46 @@ var offlineLabel = { transform: 'translate(-50%, -50%)' }; // CONCATENATED MODULE: ./src/helper/validate.js - function nullCheck(val, msg) { - if (isNull(val)) { - throw new Error(msg); - } + if (isNull(val)) { + throw new Error(msg); + } } -function numberCheck(val, msg) { - if (isNumber(val)) { - throw new Error(msg); - } +function arrayCheck(val, msg) { + if (!isArray(val)) { + throw new Error(msg); + } } function isNull(obj) { - return obj === null || obj === undefined; + return obj === null || obj === undefined; +} + +function isUndefined(obj) { + return obj === undefined; } function isNumber(obj) { - return Object.prototype.toString.call(obj) === '[object Number]'; + return Object.prototype.toString.call(obj) === '[object Number]'; } function isArray(obj) { - return Object.prototype.toString.call(obj) === '[object Array]'; + return Object.prototype.toString.call(obj) === '[object Array]'; } var CONTROL_TYPS = ['navigation', 'overviewmap', 'scale', 'maptype', 'copyright', 'geolocation', 'panorama']; function controlTypeCheck(type) { - if (CONTROL_TYPS.indexOf((type || '').toLowerCase()) < 0) { - throw new Error('control type should be one of: [' + CONTROL_TYPS.join(',') + ']'); - } + if (CONTROL_TYPS.indexOf((type || '').toLowerCase()) < 0) { + throw new Error('control type should be one of: [' + CONTROL_TYPS.join(',') + ']'); + } } var OVERLAY_TYPS = ['heatmap']; function overlayTypeCheck(type) { - if (OVERLAY_TYPS.indexOf((type || '').toLowerCase()) < 0) { - throw new Error('overlay type should be one of: [' + OVERLAY_TYPS.join(',') + ']'); - } + if (OVERLAY_TYPS.indexOf((type || '').toLowerCase()) < 0) { + throw new Error('overlay type should be one of: [' + OVERLAY_TYPS.join(',') + ']'); + } } // CONCATENATED MODULE: ./src/helper/map.js @@ -217,130 +220,139 @@ function baiduMap_classCallCheck(instance, Constructor) { if (!(instance instanc /* harmony default export */ var baiduMap = ({ - bindings: { - offlineTxt: '<', - mapOptions: '<', - loaded: '&', - click: '&' - }, - transclude: true, - template: '\n
\n
\n \n
\n
\n ', - controller: function () { - /* @ngInject */ - function controller($scope, $element, $attrs, mapScriptService) { - baiduMap_classCallCheck(this, controller); + bindings: { + offlineTxt: '<', + mapOptions: '<', + loaded: '&', + click: '&' + }, + transclude: true, + template: '\n
\n
\n \n
\n
\n ', + controller: function () { + /* @ngInject */ + function controller($scope, $element, $attrs, mapScriptService) { + baiduMap_classCallCheck(this, controller); + + this.$scope = $scope; + this.$element = $element; + this.$attrs = $attrs; + this.style = style_namespaceObject; + this.mapScriptService = mapScriptService; + } - this.$scope = $scope; - this.$element = $element; - this.$attrs = $attrs; - this.style = style_namespaceObject; - this.mapScriptService = mapScriptService; + baiduMap_createClass(controller, [{ + key: '$onInit', + value: function $onInit() { + var _this = this; + + this.mapReady = this.mapScriptService.load().then(function () { + return map_create(_this.$element.children()[0], _this.mapOptions); + }).then(function (map) { + _this.loaded({ + map: map + }); + _this.$scope.$apply(); + // eslint-disable-next-line + return _this.map = map; + }).then(function () { + if (!_this.$attrs.click) { + return; + } + var clickListener = _this.clickListener = function (e) { + _this.click({ + e: e + }); + _this.$scope.$apply(); + }; + _this.map.addEventListener('click', clickListener); + }); + } + }, { + key: '$onChanges', + value: function $onChanges(changes) { + if (!this.map) { + return; } - - baiduMap_createClass(controller, [{ - key: '$onInit', - value: function $onInit() { - var _this = this; - - this.mapReady = this.mapScriptService.load().then(function () { - return map_create(_this.$element.children()[0], _this.mapOptions); - }).then(function (map) { - _this.loaded({ - map: map - }); - _this.$scope.$apply(); - //eslint-disable-next-line - return _this.map = map; - }).then(function () { - if (!_this.$attrs.click) { - return; - } - var clickListener = _this.clickListener = function (e) { - _this.click({ - e: e - }); - _this.$scope.$apply(); - }; - _this.map.addEventListener('click', clickListener); - }); - } - }, { - key: '$onChanges', - value: function $onChanges(changes) { - if (!this.map) { - return; - } - map_refresh(this.map, changes.mapOptions.currentValue); - } - }, { - key: '$onDestroy', - value: function $onDestroy() { - this.map.removeEventListener('click', this.clickListener); - } - }, { - key: 'addOverlay', - value: function addOverlay(marker) { - return baiduMap_handleMapOperation(this.map, 'addOverlay', marker); - } - }, { - key: 'removeOverlay', - value: function removeOverlay(marker) { - return baiduMap_handleMapOperation(this.map, 'removeOverlay', marker); - } - }, { - key: 'addControl', - value: function addControl(control) { - return baiduMap_handleMapOperation(this.map, 'addControl', control); - } - }, { - key: 'removeControl', - value: function removeControl(control) { - return baiduMap_handleMapOperation(this.map, 'removeControl', control); - } - }, { - key: 'getMap', - value: function getMap() { - return this.map; - } - }]); - - return controller; - }() + map_refresh(this.map, changes.mapOptions.currentValue); + } + }, { + key: '$onDestroy', + value: function $onDestroy() { + this.map.removeEventListener('click', this.clickListener); + } + }, { + key: 'addOverlay', + value: function addOverlay(marker) { + return baiduMap_handleMapOperation(this.map, 'addOverlay', marker); + } + }, { + key: 'removeOverlay', + value: function removeOverlay(marker) { + return baiduMap_handleMapOperation(this.map, 'removeOverlay', marker); + } + }, { + key: 'addControl', + value: function addControl(control) { + return baiduMap_handleMapOperation(this.map, 'addControl', control); + } + }, { + key: 'removeControl', + value: function removeControl(control) { + return baiduMap_handleMapOperation(this.map, 'removeControl', control); + } + }, { + key: 'getMap', + value: function getMap() { + return this.map; + } + }]); + + return controller; + }() }); function baiduMap_handleMapOperation(map, method) { - for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { - args[_key - 2] = arguments[_key]; - } - - return new Promise(function (resolve) { - map[method].apply(map, args); - resolve(); - }); + for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + args[_key - 2] = arguments[_key]; + } + + return new Promise(function (resolve) { + map[method].apply(map, args); + resolve(); + }); } // CONCATENATED MODULE: ./src/helper/transformer.js function transformer_transformIcon(icon, field) { - var opts = { - url: icon.url - }; - nullCheck(icon.url, 'url is required in ' + field); - nullCheck(icon.size, 'size is required in ' + field); - opts.size = transformer_transformSize(icon.size, field + '.size'); - return new BMap.Icon(opts.url, opts.size); + var opts = { + url: icon.url + }; + nullCheck(icon.url, 'url is required in ' + field); + nullCheck(icon.size, 'size is required in ' + field); + opts.size = transformer_transformSize(icon.size, field + '.size'); + return new BMap.Icon(opts.url, opts.size); } function transformer_transformSize(size, field) { - nullCheck(size.width, 'width is required in ' + field); - nullCheck(size.height, 'height is required in ' + field); - return new BMap.Size(size.width, size.height); + nullCheck(size.width, 'width is required in ' + field); + nullCheck(size.height, 'height is required in ' + field); + return new BMap.Size(size.width, size.height); } function transformer_transformPoint(point, field) { + nullCheck(point.longitude, 'longitude is required in ' + field); + nullCheck(point.latitude, 'latitude is required in ' + field); + return new BMap.Point(point.longitude, point.latitude); +} + +function transformer_transformPoints(points, field) { + arrayCheck(points, field + ' must be Array'); + return points.map(function (point) { nullCheck(point.longitude, 'longitude is required in ' + field); nullCheck(point.latitude, 'latitude is required in ' + field); return new BMap.Point(point.longitude, point.latitude); + }); } // CONCATENATED MODULE: ./src/components/marker.js var marker_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; }; }(); @@ -351,87 +363,481 @@ function marker_classCallCheck(instance, Constructor) { if (!(instance instanceo /* harmony default export */ var components_marker = ({ - bindings: { - point: '<', - options: '<', - click: '&' - }, - require: { - mapCtrl: '^baiduMap' - }, - template: '', - controller: function () { - /* @ngInject */ - function controller($scope, $attrs) { - marker_classCallCheck(this, controller); + bindings: { + point: '<', + options: '<', + loaded: '&', + click: '&' + }, + require: { + mapCtrl: '^baiduMap' + }, + template: '', + controller: function () { + /* @ngInject */ + function controller($scope, $attrs) { + marker_classCallCheck(this, controller); + + this.$scope = $scope; + this.$attrs = $attrs; + } - this.$scope = $scope; - this.$attrs = $attrs; + marker_createClass(controller, [{ + key: '$onInit', + value: function $onInit() { + var _this = this; + + nullCheck(this.point, 'point is required for '); + + this.mapCtrl.mapReady.then(function () { + var point = transformer_transformPoint(_this.point, ' point'); + var opts = marker_transformOptions(_this.options); + var marker = _this.marker = new BMap.Marker(point, opts); + _this.mapCtrl.addOverlay(marker); + return marker; + }).then(function (marker) { + _this.loaded({ + marker: marker + }); + _this.$scope.$apply(); + + if (!_this.$attrs.click) { + return; + } + _this.clickHandler = function (e) { + _this.click({ + e: e, + marker: marker, + map: _this.mapCtrl.getMap() + }); + _this.$scope.$apply(); + }; + marker.addEventListener('click', _this.clickHandler); + }); + } + }, { + key: '$onChanges', + value: function $onChanges(changes) { + if (!this.marker) { + return; + } + if (changes.point && changes.point.currentValue) { + this.marker.setPosition(transformer_transformPoint(changes.point.currentValue, ' point')); } + } + }, { + key: '$onDestroy', + value: function $onDestroy() { + this.marker.removeEventListener('click', this.clickHandler); + this.mapCtrl.removeOverlay(this.marker); + } + }]); + + return controller; + }() +}); - marker_createClass(controller, [{ - key: '$onInit', - value: function $onInit() { - var _this = this; +function marker_transformOptions(options) { + var opts = JSON.parse(JSON.stringify(options || {})); + if (opts.offset) { + opts.offset = transformer_transformSize(opts.offset, ' options.offset'); + } + if (opts.icon) { + opts.icon = transformer_transformIcon(opts.icon, ' options.icon'); + } + if (opts.shadow) { + opts.shadow = transformer_transformIcon(opts.shadow, ' options.shadow'); + } + return opts; +} +// CONCATENATED MODULE: ./src/components/polyline.js +var polyline_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; }; }(); - nullCheck(this.point, 'point is required for '); +function polyline_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - this.mapCtrl.mapReady.then(function () { - var point = transformer_transformPoint(_this.point, ' point'); - var opts = marker_transformOptions(_this.options); - var marker = _this.marker = new BMap.Marker(point, opts); - _this.mapCtrl.addOverlay(marker); - return marker; - }).then(function (marker) { - if (!_this.$attrs.click) { - return; - } - _this.clickHandler = function (e) { - _this.click({ - e: e, - marker: marker, - map: _this.mapCtrl.getMap() - }); - _this.$scope.$apply(); - }; - marker.addEventListener('click', _this.clickHandler); - }); - } - }, { - key: '$onChanges', - value: function $onChanges(changes) { - if (!this.marker) { - return; - } - if (changes.point && changes.point.currentValue) { - this.marker.setPosition(transformer_transformPoint(changes.point.currentValue, ' point')); - } - } - }, { - key: '$onDestroy', - value: function $onDestroy() { - this.marker.removeEventListener('click', this.clickHandler); - this.mapCtrl.removeOverlay(this.marker); - } - }]); - return controller; - }() -}); -function marker_transformOptions(options) { - var opts = JSON.parse(JSON.stringify(options || {})); - if (opts.offset) { - opts.offset = transformer_transformSize(opts.offset, ' options.offset'); + +/* harmony default export */ var components_polyline = ({ + bindings: { + points: '<', + options: '<', + loaded: '&' + }, + require: { + mapCtrl: '^baiduMap' + }, + template: '', + controller: function () { + /* @ngInject */ + function controller($scope, $attrs) { + polyline_classCallCheck(this, controller); + + this.$scope = $scope; + this.$attrs = $attrs; } - if (opts.icon) { - opts.icon = transformer_transformIcon(opts.icon, ' options.icon'); + + polyline_createClass(controller, [{ + key: '$onInit', + value: function $onInit() { + var _this = this; + + nullCheck(this.points, 'points is required for '); + + this.mapCtrl.mapReady.then(function () { + var points = transformer_transformPoints(_this.points, ' points'); + var opts = _this.options; + var polyline = _this.polyline = new BMap.Polyline(points, opts); + _this.mapCtrl.addOverlay(polyline); + return polyline; + }).then(function (polyline) { + _this.loaded({ + polyline: polyline + }); + _this.$scope.$apply(); + }); + } + }, { + key: '$onChanges', + value: function $onChanges(changes) { + if (!this.polyline) { + return; + } + if (changes.points && changes.points.currentValue) { + this.polyline.setPath(transformer_transformPoints(changes.points.currentValue, ' points')); + } + if (!changes.options || !changes.options.currentValue) { + return; + } + if (!isUndefined(changes.options.currentValue.strokeColor)) { + this.polyline.setStrokeColor(changes.options.currentValue.strokeColor); + } + if (!isUndefined(changes.options.currentValue.strokeWeight)) { + this.polyline.setStrokeWeight(changes.options.currentValue.strokeWeight); + } + if (!isUndefined(changes.options.currentValue.strokeOpacity)) { + this.polyline.setStrokeOpacity(changes.options.currentValue.strokeOpacity); + } + if (!isUndefined(changes.options.currentValue.strokeStyle)) { + this.polyline.setStrokeStyle(changes.options.currentValue.strokeStyle); + } + + if (!isUndefined(changes.options.currentValue.enableMassClear)) { + this.polyline[changes.options.currentValue.enableMassClear ? 'enableMassClear' : 'disableMassClear'](); + } + if (!isUndefined(changes.options.currentValue.enableEditing)) { + this.polyline[changes.options.currentValue.enableEditing ? 'enableEditing' : 'disableEditing'](); + } + } + }, { + key: '$onDestroy', + value: function $onDestroy() { + this.mapCtrl.removeOverlay(this.polyline); + } + }]); + + return controller; + }() +}); +// CONCATENATED MODULE: ./src/components/circle.js +var circle_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; }; }(); + +function circle_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + + + +/* harmony default export */ var components_circle = ({ + bindings: { + center: '<', + radius: '<', + options: '<', + loaded: '&' + }, + require: { + mapCtrl: '^baiduMap' + }, + template: '', + controller: function () { + /* @ngInject */ + function controller($scope, $attrs) { + circle_classCallCheck(this, controller); + + this.$scope = $scope; + this.$attrs = $attrs; } - if (opts.shadow) { - opts.shadow = transformer_transformIcon(opts.shadow, ' options.shadow'); + + circle_createClass(controller, [{ + key: '$onInit', + value: function $onInit() { + var _this = this; + + nullCheck(this.center, 'center is required for '); + nullCheck(this.radius, 'radius is required for '); + + this.mapCtrl.mapReady.then(function () { + var center = _this.center, + radius = _this.radius, + options = _this.options; + + var point = transformer_transformPoint(center, ' center'); + var circle = _this.circle = new BMap.Circle(point, radius, options); + _this.mapCtrl.addOverlay(circle); + return circle; + }).then(function (circle) { + _this.loaded({ + circle: circle + }); + _this.$scope.$apply(); + }); + } + }, { + key: '$onChanges', + value: function $onChanges(changes) { + if (!this.circle) { + return; + } + if (changes.center && changes.center.currentValue) { + this.circle.setCenter(transformer_transformPoint(changes.center.currentValue, ' center')); + } + if (changes.radius && changes.radius.currentValue) { + this.circle.setRadius(changes.radius.currentValue); + } + if (!changes.options || !changes.options.currentValue) { + return; + } + + if (!isUndefined(changes.options.currentValue.strokeColor)) { + this.circle.setStrokeColor(changes.options.currentValue.strokeColor); + } + if (!isUndefined(changes.options.currentValue.strokeWeight)) { + this.circle.setStrokeWeight(changes.options.currentValue.strokeWeight); + } + if (!isUndefined(changes.options.currentValue.strokeOpacity)) { + this.circle.setStrokeOpacity(changes.options.currentValue.strokeOpacity); + } + if (!isUndefined(changes.options.currentValue.strokeStyle)) { + this.circle.setStrokeStyle(changes.options.currentValue.strokeStyle); + } + if (!isUndefined(changes.options.currentValue.fillOpacity)) { + this.circle.setFillOpacity(changes.options.currentValue.fillOpacity); + } + if (!isUndefined(changes.options.currentValue.fillColor)) { + this.circle.setFillColor(changes.options.currentValue.fillColor); + } + + if (!isUndefined(changes.options.currentValue.enableMassClear)) { + this.circle[changes.options.currentValue.enableMassClear ? 'enableMassClear' : 'disableMassClear'](); + } + + if (!isUndefined(changes.options.currentValue.enableEditing)) { + this.circle[changes.options.currentValue.enableEditing ? 'enableEditing' : 'disableEditing'](); + } + } + }, { + key: '$onDestroy', + value: function $onDestroy() { + this.mapCtrl.removeOverlay(this.circle); + } + }]); + + return controller; + }() +}); +// CONCATENATED MODULE: ./src/components/polygon.js +var polygon_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; }; }(); + +function polygon_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + + + +/* harmony default export */ var components_polygon = ({ + bindings: { + points: '<', + options: '<', + loaded: '&' + }, + require: { + mapCtrl: '^baiduMap' + }, + template: '', + controller: function () { + /* @ngInject */ + function controller($scope, $attrs) { + polygon_classCallCheck(this, controller); + + this.$scope = $scope; + this.$attrs = $attrs; } - return opts; + + polygon_createClass(controller, [{ + key: '$onInit', + value: function $onInit() { + var _this = this; + + nullCheck(this.points, 'points is required for '); + + this.mapCtrl.mapReady.then(function () { + var points = transformer_transformPoints(_this.points, ' points'); + var opts = _this.options; + var polygon = _this.polygon = new BMap.Polygon(points, opts); + _this.mapCtrl.addOverlay(polygon); + return polygon; + }).then(function (polygon) { + _this.loaded({ + polygon: polygon + }); + _this.$scope.$apply(); + }); + } + }, { + key: '$onChanges', + value: function $onChanges(changes) { + if (!this.polygon) { + return; + } + if (changes.points && changes.points.currentValue) { + this.polygon.setPath(transformer_transformPoints(changes.points.currentValue, ' points')); + } + if (!changes.options || !changes.options.currentValue) { + return; + } + if (!isUndefined(changes.options.currentValue.strokeColor)) { + this.polygon.setStrokeColor(changes.options.currentValue.strokeColor); + } + if (!isUndefined(changes.options.currentValue.fillColor)) { + this.polygon.setFillColor(changes.options.currentValue.fillColor); + } + if (!isUndefined(changes.options.currentValue.strokeWeight)) { + this.polygon.setStrokeWeight(changes.options.currentValue.strokeWeight); + } + if (!isUndefined(changes.options.currentValue.strokeOpacity)) { + this.polygon.setStrokeOpacity(changes.options.currentValue.strokeOpacity); + } + if (!isUndefined(changes.options.currentValue.fillOpacity)) { + this.polygon.setFillOpacity(changes.options.currentValue.fillOpacity); + } + if (!isUndefined(changes.options.currentValue.strokeStyle)) { + this.polygon.setStrokeStyle(changes.options.currentValue.strokeStyle); + } + + if (!isUndefined(changes.options.currentValue.enableMassClear)) { + this.polygon[changes.options.currentValue.enableMassClear ? 'enableMassClear' : 'disableMassClear'](); + } + if (!isUndefined(changes.options.currentValue.enableEditing)) { + this.polygon[changes.options.currentValue.enableEditing ? 'enableEditing' : 'disableEditing'](); + } + } + }, { + key: '$onDestroy', + value: function $onDestroy() { + this.mapCtrl.removeOverlay(this.polygon); + } + }]); + + return controller; + }() +}); +// CONCATENATED MODULE: ./src/helper/heatmapScriptLoader.js +var SCRIPT_URL = '//api.map.baidu.com/library/Heatmap/2.0/src/Heatmap_min.js'; + +/* harmony default export */ var heatmapScriptLoader = (function () { + var loadHeatMapPromise = window.loadHeatMapPromise; + if (loadHeatMapPromise) { + return loadHeatMapPromise; + } + + // eslint-disable-next-line + return window.loadHeatMapPromise = heatmapScriptLoader_appendScriptTag(SCRIPT_URL); +}); + +function heatmapScriptLoader_appendScriptTag(url) { + return new Promise(function (resolve, reject) { + var script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = url; + script.onerror = function () { + document.body.removeChild(script); + + setTimeout(function () { + heatmapScriptLoader_appendScriptTag(url); + }, 30000); + }; + script.onload = resolve; + document.body.appendChild(script); + }); } +// CONCATENATED MODULE: ./src/components/heatmap.js +var heatmap_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; }; }(); + +function heatmap_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + + +/* harmony default export */ var heatmap = ({ + bindings: { + dataset: '<', + options: '<', + loaded: '&' + }, + require: { + mapCtrl: '^baiduMap' + }, + template: '', + controller: function () { + /* @ngInject */ + function controller($scope, $attrs) { + heatmap_classCallCheck(this, controller); + + this.$scope = $scope; + this.$attrs = $attrs; + } + + heatmap_createClass(controller, [{ + key: '$onInit', + value: function $onInit() { + var _this = this; + + this.mapCtrl.mapReady.then(function () { + return heatmapScriptLoader(); + }).then(function () { + var heatmap = _this.heatmap = new BMapLib.HeatmapOverlay(_this.options); + _this.mapCtrl.addOverlay(heatmap); + return heatmap; + }).then(function (heatmap) { + _this.loaded({ + heatmap: heatmap + }); + _this.$scope.$apply(); + if (_this.dataset) { + heatmap.setDataSet(_this.dataset); + } + }); + } + }, { + key: '$onChanges', + value: function $onChanges(changes) { + if (!this.heatmap) { + return; + } + if (changes.options && changes.options.currentValue) { + this.heatmap.setOptions(changes.options.currentValue); + } + if (changes.dataset && changes.dataset.currentValue) { + this.heatmap.setDataSet(changes.dataset.currentValue); + } + } + }, { + key: '$onDestroy', + value: function $onDestroy() { + this.mapCtrl.removeOverlay(this.heatmap); + } + }]); + + return controller; + }() +}); // CONCATENATED MODULE: ./src/components/control.js var control_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; }; }(); @@ -509,44 +915,13 @@ function control_createControl(type, options) { return new BMap.PanoramaControl(options); } } -// CONCATENATED MODULE: ./src/helper/heatmapScriptLoader.js - -var SCRIPT_URL = '//api.map.baidu.com/library/Heatmap/2.0/src/Heatmap_min.js'; - -/* harmony default export */ var heatmapScriptLoader = (function () { - - var loadHeatMapPromise = window.loadHeatMapPromise; - if (loadHeatMapPromise) { - return loadHeatMapPromise; - } - - //eslint-disable-next-line - return window.loadHeatMapPromise = heatmapScriptLoader_appendScriptTag(SCRIPT_URL); -}); - -function heatmapScriptLoader_appendScriptTag(url) { - return new Promise(function (resolve, reject) { - var script = document.createElement('script'); - script.type = 'text/javascript'; - script.src = url; - script.onerror = function () { - document.body.removeChild(script); - - setTimeout(function () { - heatmapScriptLoader_appendScriptTag(url); - }, 30000); - }; - script.onload = resolve; - document.body.appendChild(script); - }); -} // CONCATENATED MODULE: ./src/components/heatmap/index.js function heatmap_createHeatmapOverlay(options) { - return heatmapScriptLoader().then(function () { - return new BMapLib.HeatmapOverlay(options); - }); + return heatmapScriptLoader().then(function () { + return new BMapLib.HeatmapOverlay(options); + }); } // CONCATENATED MODULE: ./src/components/overlay.js var overlay_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; }; }(); @@ -557,69 +932,69 @@ function overlay_classCallCheck(instance, Constructor) { if (!(instance instance /* harmony default export */ var overlay = ({ - bindings: { - type: '@', - options: '<', - dataset: '<' - }, - require: { - mapCtrl: '^baiduMap' - }, - template: '', - controller: function () { - /* @ngInject */ - function controller() { - overlay_classCallCheck(this, controller); - } + bindings: { + type: '@', + options: '<', + dataset: '<' + }, + require: { + mapCtrl: '^baiduMap' + }, + template: '', + controller: function () { + function controller() { + overlay_classCallCheck(this, controller); + } - overlay_createClass(controller, [{ - key: '$onInit', - value: function $onInit() { - var _this = this; + overlay_createClass(controller, [{ + key: '$onInit', + value: function $onInit() { + var _this = this; - overlayTypeCheck(this.type); + overlayTypeCheck(this.type); - this.realType = this.type.toLowerCase(); + this.realType = this.type.toLowerCase(); - this.mapCtrl.mapReady.then(function () { - return overlay_createOverlay(_this.realType, _this.options); - }).then(function (overlay) { - _this.mapCtrl.addOverlay(overlay); - _this.overlay = overlay; - overlay_setExtraData(_this.realType, _this.overlay, _this.dataset); - return overlay; - }); - } - }, { - key: '$onChanges', - value: function $onChanges(changes) { - if (changes.dataset && changes.dataset.currentValue) { - overlay_setExtraData(this.realType, this.overlay, changes.dataset.currentValue); - } - } - }, { - key: '$onDestroy', - value: function $onDestroy() { - this.mapCtrl.removeOverlay(this.overlay); - } - }]); - - return controller; - }() + this.mapCtrl.mapReady.then(function () { + return overlay_createOverlay(_this.realType, _this.options); + }).then(function (overlay) { + _this.mapCtrl.addOverlay(overlay); + _this.overlay = overlay; + overlay_setExtraData(_this.realType, _this.overlay, _this.dataset); + return overlay; + }); + } + }, { + key: '$onChanges', + value: function $onChanges(changes) { + if (changes.dataset && changes.dataset.currentValue) { + overlay_setExtraData(this.realType, this.overlay, changes.dataset.currentValue); + } + } + }, { + key: '$onDestroy', + value: function $onDestroy() { + this.mapCtrl.removeOverlay(this.overlay); + } + }]); + + return controller; + }() }); function overlay_createOverlay(type, options) { - if (type === 'heatmap') { - return heatmap_createHeatmapOverlay(options); - } + if (type === 'heatmap') { + console.warn('heatmap type is deprecated, please try with new component, see: https://leftstick.github.io/BaiduMapForAngularJS/#!/apidoc?api=heatmap'); + return heatmap_createHeatmapOverlay(options); + } } function overlay_setExtraData(type, overlay, data) { - if (type === 'heatmap') { - if (data) { - overlay.setDataSet(data); - } + if (type === 'heatmap') { + if (data) { + overlay.setDataSet(data); } + } } // CONCATENATED MODULE: ./src/provider/mapScript.js @@ -746,10 +1121,14 @@ function globalConstants() { + + + + globalConstants(); var src_moduleName = 'baiduMap'; -external_angular_default.a.module(src_moduleName, []).provider('mapScriptService', mapScript).component('baiduMap', baiduMap).component('marker', components_marker).component('control', control).component('overlay', overlay); +external_angular_default.a.module(src_moduleName, []).provider('mapScriptService', mapScript).component('baiduMap', baiduMap).component('marker', components_marker).component('polyline', components_polyline).component('circle', components_circle).component('polygon', components_polygon).component('heatmap', heatmap).component('control', control).component('overlay', overlay); var src_ngBaiduMap = src_moduleName; diff --git a/dist/angular-baidu-map.min.js b/dist/angular-baidu-map.min.js index d07c902..10f6362 100644 --- a/dist/angular-baidu-map.min.js +++ b/dist/angular-baidu-map.min.js @@ -1 +1 @@ -!function(e,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n(require("angular"));else if("function"==typeof define&&define.amd)define(["angular"],n);else{var t="object"==typeof exports?n(require("angular")):n(e.angular);for(var o in t)("object"==typeof exports?exports:e)[o]=t[o]}}(window,function(e){return function(e){var n={};function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}return t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=1)}([function(n,t){n.exports=e},function(e,n,t){"use strict";t.r(n);var o={};t.d(o,"map",function(){return a}),t.d(o,"offline",function(){return l}),t.d(o,"offlineLabel",function(){return u});var r=t(0),i=t.n(r),a={width:"100%",height:"100%",display:"none"},l={width:"100%",height:"100%",backgroundColor:"#E6E6E6",position:"relative",display:"none"},u={fontSize:"30px",margin:0,position:"absolute",top:"50%",left:"50%","margin-right":"-50%",transform:"translate(-50%, -50%)"};function c(e,n){if(s(e))throw new Error(n)}function s(e){return null===e||void 0===e}var p=["navigation","overviewmap","scale","maptype","copyright","geolocation","panorama"];var d=["heatmap"];var f={longitude:121.506191,latitude:31.245554},m=10;function y(e,n){s(n)||s(n.disableDragging)||e[(n.disableDragging?"disable":"enable")+"Dragging"](),s(n)||s(n.enableScrollWheelZoom)||e[(n.enableScrollWheelZoom?"enable":"disable")+"ScrollWheelZoom"](),s(n)||s(n.disableDoubleClickZoom)||e[(n.disableDoubleClickZoom?"disable":"enable")+"DoubleClickZoom"](),s(n)||s(n.enableKeyboard)||e[(n.enableKeyboard?"enable":"disable")+"Keyboard"](),s(n)||s(n.enableInertialDragging)||e[(n.enableInertialDragging?"enable":"disable")+"InertialDragging"](),s(n)||s(n.enableContinuousZoom)||e[(n.enableContinuousZoom?"enable":"disable")+"ContinuousZoom"](),s(n)||s(n.disablePinchToZoom)||e[(n.disablePinchToZoom?"disable":"enable")+"PinchToZoom"](),!s(n)&&!s(n.cursor)&&e.setDefaultCursor(n.cursor),!s(n)&&!s(n.draggingCursor)&&e.setDraggingCursor(n.draggingCursor),!s(n)&&!s(n.currentCity)&&e.setCurrentCity(n.currentCity),!s(n)&&!s(n.centerAndZoom)&&e.centerAndZoom(new BMap.Point(n.centerAndZoom.longitude||f.longitude,n.centerAndZoom.latitude||f.latitude),n.centerAndZoom.zoom||m)}var h=function(){function e(e,n){for(var t=0;t\n
\n \n
\n
\n ',controller:function(){function e(n,t,r,i){!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e),this.$scope=n,this.$element=t,this.$attrs=r,this.style=o,this.mapScriptService=i}return e.$inject=["$scope","$element","$attrs","mapScriptService"],h(e,[{key:"$onInit",value:function(){var e=this;this.mapReady=this.mapScriptService.load().then(function(){return n=e.$element.children()[0],t=e.mapOptions,y(o=new BMap.Map(n,t),t),o;var n,t,o}).then(function(n){return e.loaded({map:n}),e.$scope.$apply(),e.map=n}).then(function(){if(e.$attrs.click){var n=e.clickListener=function(n){e.click({e:n}),e.$scope.$apply()};e.map.addEventListener("click",n)}})}},{key:"$onChanges",value:function(e){this.map&&y(this.map,e.mapOptions.currentValue)}},{key:"$onDestroy",value:function(){this.map.removeEventListener("click",this.clickListener)}},{key:"addOverlay",value:function(e){return w(this.map,"addOverlay",e)}},{key:"removeOverlay",value:function(e){return w(this.map,"removeOverlay",e)}},{key:"addControl",value:function(e){return w(this.map,"addControl",e)}},{key:"removeControl",value:function(e){return w(this.map,"removeControl",e)}},{key:"getMap",value:function(){return this.map}}]),e}()};function w(e,n){for(var t=arguments.length,o=Array(t>2?t-2:0),r=2;r"),this.mapCtrl.mapReady.then(function(){var n=O(e.point," point"),t=function(e){var n=JSON.parse(JSON.stringify(e||{}));n.offset&&(n.offset=A(n.offset," options.offset"));n.icon&&(n.icon=b(n.icon," options.icon"));n.shadow&&(n.shadow=b(n.shadow," options.shadow"));return n}(e.options),o=e.marker=new BMap.Marker(n,t);return e.mapCtrl.addOverlay(o),o}).then(function(n){e.$attrs.click&&(e.clickHandler=function(t){e.click({e:t,marker:n,map:e.mapCtrl.getMap()}),e.$scope.$apply()},n.addEventListener("click",e.clickHandler))})}},{key:"$onChanges",value:function(e){this.marker&&e.point&&e.point.currentValue&&this.marker.setPosition(O(e.point.currentValue," point"))}},{key:"$onDestroy",value:function(){this.marker.removeEventListener("click",this.clickHandler),this.mapCtrl.removeOverlay(this.marker)}}]),e}()};var M=function(){function e(e,n){for(var t=0;t-1?n+"&s="+("https:"===location.protocol?1:0):"https:"+n+"&s=1"},this.$get=["$rootScope",function(t){"ngInject";return{load:function(){c(e,"ak should be set before use. Read: https://leftstick.github.io/BaiduMapForAngularJS/#!/quickstart");var o=t.loadBaiduMapPromise;return o?o.then(I):t.loadBaiduMapPromise=new Promise(function(e,t){window.baidumapinit=e,function e(n){var t=document.createElement("script");t.type="text/javascript",t.src=n,t.onerror=function(){Array.prototype.slice.call(document.querySelectorAll("baidu-map .baidu-map-offline")).forEach(function(e){e.style.display="block"}),document.body.removeChild(t),setTimeout(function(){e(n)},3e4)},document.body.appendChild(t)}(n)}).then(I)}}}]}).component("baiduMap",v).component("marker",g).component("control",P).component("overlay",k);var B="baiduMap"}])}); \ No newline at end of file +!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("angular"));else if("function"==typeof define&&define.amd)define(["angular"],t);else{var n="object"==typeof exports?t(require("angular")):t(e.angular);for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(window,function(e){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:o})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(t,n){t.exports=e},function(e,t,n){"use strict";n.r(t);var o={};n.d(o,"map",function(){return a}),n.d(o,"offline",function(){return l}),n.d(o,"offlineLabel",function(){return u});var r=n(0),i=n.n(r),a={width:"100%",height:"100%",display:"none"},l={width:"100%",height:"100%",backgroundColor:"#E6E6E6",position:"relative",display:"none"},u={fontSize:"30px",margin:0,position:"absolute",top:"50%",left:"50%","margin-right":"-50%",transform:"translate(-50%, -50%)"};function s(e,t){if(c(e))throw new Error(t)}function c(e){return null===e||void 0===e}function p(e){return void 0===e}function d(e){return"[object Array]"===Object.prototype.toString.call(e)}var f=["navigation","overviewmap","scale","maptype","copyright","geolocation","panorama"];var y=["heatmap"];var h={longitude:121.506191,latitude:31.245554},m=10;function v(e,t){c(t)||c(t.disableDragging)||e[(t.disableDragging?"disable":"enable")+"Dragging"](),c(t)||c(t.enableScrollWheelZoom)||e[(t.enableScrollWheelZoom?"enable":"disable")+"ScrollWheelZoom"](),c(t)||c(t.disableDoubleClickZoom)||e[(t.disableDoubleClickZoom?"disable":"enable")+"DoubleClickZoom"](),c(t)||c(t.enableKeyboard)||e[(t.enableKeyboard?"enable":"disable")+"Keyboard"](),c(t)||c(t.enableInertialDragging)||e[(t.enableInertialDragging?"enable":"disable")+"InertialDragging"](),c(t)||c(t.enableContinuousZoom)||e[(t.enableContinuousZoom?"enable":"disable")+"ContinuousZoom"](),c(t)||c(t.disablePinchToZoom)||e[(t.disablePinchToZoom?"disable":"enable")+"PinchToZoom"](),!c(t)&&!c(t.cursor)&&e.setDefaultCursor(t.cursor),!c(t)&&!c(t.draggingCursor)&&e.setDraggingCursor(t.draggingCursor),!c(t)&&!c(t.currentCity)&&e.setCurrentCity(t.currentCity),!c(t)&&!c(t.centerAndZoom)&&e.centerAndZoom(new BMap.Point(t.centerAndZoom.longitude||h.longitude,t.centerAndZoom.latitude||h.latitude),t.centerAndZoom.zoom||m)}var b=function(){function e(e,t){for(var n=0;n\n
\n \n
\n
\n ',controller:function(){function e(t,n,r,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.$scope=t,this.$element=n,this.$attrs=r,this.style=o,this.mapScriptService=i}return e.$inject=["$scope","$element","$attrs","mapScriptService"],b(e,[{key:"$onInit",value:function(){var e=this;this.mapReady=this.mapScriptService.load().then(function(){return t=e.$element.children()[0],n=e.mapOptions,v(o=new BMap.Map(t,n),n),o;var t,n,o}).then(function(t){return e.loaded({map:t}),e.$scope.$apply(),e.map=t}).then(function(){if(e.$attrs.click){var t=e.clickListener=function(t){e.click({e:t}),e.$scope.$apply()};e.map.addEventListener("click",t)}})}},{key:"$onChanges",value:function(e){this.map&&v(this.map,e.mapOptions.currentValue)}},{key:"$onDestroy",value:function(){this.map.removeEventListener("click",this.clickListener)}},{key:"addOverlay",value:function(e){return w(this.map,"addOverlay",e)}},{key:"removeOverlay",value:function(e){return w(this.map,"removeOverlay",e)}},{key:"addControl",value:function(e){return w(this.map,"addControl",e)}},{key:"removeControl",value:function(e){return w(this.map,"removeControl",e)}},{key:"getMap",value:function(){return this.map}}]),e}()};function w(e,t){for(var n=arguments.length,o=Array(n>2?n-2:0),r=2;r"),this.mapCtrl.mapReady.then(function(){var t=k(e.point," point"),n=function(e){var t=JSON.parse(JSON.stringify(e||{}));t.offset&&(t.offset=O(t.offset," options.offset"));t.icon&&(t.icon=C(t.icon," options.icon"));t.shadow&&(t.shadow=C(t.shadow," options.shadow"));return t}(e.options),o=e.marker=new BMap.Marker(t,n);return e.mapCtrl.addOverlay(o),o}).then(function(t){e.loaded({marker:t}),e.$scope.$apply(),e.$attrs.click&&(e.clickHandler=function(n){e.click({e:n,marker:t,map:e.mapCtrl.getMap()}),e.$scope.$apply()},t.addEventListener("click",e.clickHandler))})}},{key:"$onChanges",value:function(e){this.marker&&e.point&&e.point.currentValue&&this.marker.setPosition(k(e.point.currentValue," point"))}},{key:"$onDestroy",value:function(){this.marker.removeEventListener("click",this.clickHandler),this.mapCtrl.removeOverlay(this.marker)}}]),e}()};var _=function(){function e(e,t){for(var n=0;n"),this.mapCtrl.mapReady.then(function(){var t=M(e.points," points"),n=e.options,o=e.polyline=new BMap.Polyline(t,n);return e.mapCtrl.addOverlay(o),o}).then(function(t){e.loaded({polyline:t}),e.$scope.$apply()})}},{key:"$onChanges",value:function(e){this.polyline&&(e.points&&e.points.currentValue&&this.polyline.setPath(M(e.points.currentValue," points")),e.options&&e.options.currentValue&&(p(e.options.currentValue.strokeColor)||this.polyline.setStrokeColor(e.options.currentValue.strokeColor),p(e.options.currentValue.strokeWeight)||this.polyline.setStrokeWeight(e.options.currentValue.strokeWeight),p(e.options.currentValue.strokeOpacity)||this.polyline.setStrokeOpacity(e.options.currentValue.strokeOpacity),p(e.options.currentValue.strokeStyle)||this.polyline.setStrokeStyle(e.options.currentValue.strokeStyle),p(e.options.currentValue.enableMassClear)||this.polyline[e.options.currentValue.enableMassClear?"enableMassClear":"disableMassClear"](),p(e.options.currentValue.enableEditing)||this.polyline[e.options.currentValue.enableEditing?"enableEditing":"disableEditing"]()))}},{key:"$onDestroy",value:function(){this.mapCtrl.removeOverlay(this.polyline)}}]),e}()},V=function(){function e(e,t){for(var n=0;n"),s(this.radius,"radius is required for "),this.mapCtrl.mapReady.then(function(){var t=e.center,n=e.radius,o=e.options,r=k(t," center"),i=e.circle=new BMap.Circle(r,n,o);return e.mapCtrl.addOverlay(i),i}).then(function(t){e.loaded({circle:t}),e.$scope.$apply()})}},{key:"$onChanges",value:function(e){this.circle&&(e.center&&e.center.currentValue&&this.circle.setCenter(k(e.center.currentValue," center")),e.radius&&e.radius.currentValue&&this.circle.setRadius(e.radius.currentValue),e.options&&e.options.currentValue&&(p(e.options.currentValue.strokeColor)||this.circle.setStrokeColor(e.options.currentValue.strokeColor),p(e.options.currentValue.strokeWeight)||this.circle.setStrokeWeight(e.options.currentValue.strokeWeight),p(e.options.currentValue.strokeOpacity)||this.circle.setStrokeOpacity(e.options.currentValue.strokeOpacity),p(e.options.currentValue.strokeStyle)||this.circle.setStrokeStyle(e.options.currentValue.strokeStyle),p(e.options.currentValue.fillOpacity)||this.circle.setFillOpacity(e.options.currentValue.fillOpacity),p(e.options.currentValue.fillColor)||this.circle.setFillColor(e.options.currentValue.fillColor),p(e.options.currentValue.enableMassClear)||this.circle[e.options.currentValue.enableMassClear?"enableMassClear":"disableMassClear"](),p(e.options.currentValue.enableEditing)||this.circle[e.options.currentValue.enableEditing?"enableEditing":"disableEditing"]()))}},{key:"$onDestroy",value:function(){this.mapCtrl.removeOverlay(this.circle)}}]),e}()},T=function(){function e(e,t){for(var n=0;n"),this.mapCtrl.mapReady.then(function(){var t=M(e.points," points"),n=e.options,o=e.polygon=new BMap.Polygon(t,n);return e.mapCtrl.addOverlay(o),o}).then(function(t){e.loaded({polygon:t}),e.$scope.$apply()})}},{key:"$onChanges",value:function(e){this.polygon&&(e.points&&e.points.currentValue&&this.polygon.setPath(M(e.points.currentValue," points")),e.options&&e.options.currentValue&&(p(e.options.currentValue.strokeColor)||this.polygon.setStrokeColor(e.options.currentValue.strokeColor),p(e.options.currentValue.fillColor)||this.polygon.setFillColor(e.options.currentValue.fillColor),p(e.options.currentValue.strokeWeight)||this.polygon.setStrokeWeight(e.options.currentValue.strokeWeight),p(e.options.currentValue.strokeOpacity)||this.polygon.setStrokeOpacity(e.options.currentValue.strokeOpacity),p(e.options.currentValue.fillOpacity)||this.polygon.setFillOpacity(e.options.currentValue.fillOpacity),p(e.options.currentValue.strokeStyle)||this.polygon.setStrokeStyle(e.options.currentValue.strokeStyle),p(e.options.currentValue.enableMassClear)||this.polygon[e.options.currentValue.enableMassClear?"enableMassClear":"disableMassClear"](),p(e.options.currentValue.enableEditing)||this.polygon[e.options.currentValue.enableEditing?"enableEditing":"disableEditing"]()))}},{key:"$onDestroy",value:function(){this.mapCtrl.removeOverlay(this.polygon)}}]),e}()},I=function(){var e=window.loadHeatMapPromise;return e||(window.loadHeatMapPromise=function e(t){return new Promise(function(n,o){var r=document.createElement("script");r.type="text/javascript",r.src=t,r.onerror=function(){document.body.removeChild(r),setTimeout(function(){e(t)},3e4)},r.onload=n,document.body.appendChild(r)})}("//api.map.baidu.com/library/Heatmap/2.0/src/Heatmap_min.js"))};var N=function(){function e(e,t){for(var n=0;n component, see: https://leftstick.github.io/BaiduMapForAngularJS/#!/apidoc?api=heatmap"),function(e){return I().then(function(){return new BMapLib.HeatmapOverlay(e)})}(t)}(e.realType,e.options)}).then(function(t){return e.mapCtrl.addOverlay(t),e.overlay=t,D(e.realType,e.overlay,e.dataset),t})}},{key:"$onChanges",value:function(e){e.dataset&&e.dataset.currentValue&&D(this.realType,this.overlay,e.dataset.currentValue)}},{key:"$onDestroy",value:function(){this.mapCtrl.removeOverlay(this.overlay)}}]),e}()};function D(e,t,n){"heatmap"===e&&n&&t.setDataSet(n)}function Z(){return Array.prototype.slice.call(document.querySelectorAll("baidu-map")).forEach(function(e){e.querySelector(".baidu-map-offline")&&e.removeChild(e.querySelector(".baidu-map-offline")),e.querySelector(".baidu-map-instance").style.display="block"})}n.d(t,"ngBaiduMap",function(){return x}),window.BMAP_ANCHOR_TOP_LEFT=0,window.BMAP_ANCHOR_TOP_RIGHT=1,window.BMAP_ANCHOR_BOTTOM_LEFT=2,window.BMAP_ANCHOR_BOTTOM_RIGHT=3,window.BMAP_NAVIGATION_CONTROL_LARGE=0,window.BMAP_NAVIGATION_CONTROL_SMALL=1,window.BMAP_NAVIGATION_CONTROL_PAN=2,window.BMAP_NAVIGATION_CONTROL_ZOOM=3,window.BMAP_UNIT_METRIC="metric",window.BMAP_UNIT_IMPERIAL="us",window.BMAP_MAPTYPE_CONTROL_HORIZONTAL=0,window.BMAP_MAPTYPE_CONTROL_DROPDOWN=1,window.BMAP_MAPTYPE_CONTROL_MAP=2,window.BMAP_ANIMATION_DROP=1,window.BMAP_ANIMATION_BOUNCE=2,window.BMAP_POINT_SIZE_TINY=1,window.BMAP_POINT_SIZE_SMALLER=2,window.BMAP_POINT_SIZE_SMALL=3,window.BMAP_POINT_SIZE_NORMAL=4,window.BMAP_POINT_SIZE_BIG=5,window.BMAP_POINT_SIZE_BIGGER=6,window.BMAP_POINT_SIZE_HUGE=7,window.BMAP_PANORAMA_INDOOR_SCENE="inter",window.BMAP_PANORAMA_STREET_SCENE="street",window.BMAP_PANORAMA_POI_HOTEL="hotel",window.BMAP_PANORAMA_POI_CATERING="catering",window.BMAP_PANORAMA_POI_MOVIE="movie",window.BMAP_PANORAMA_POI_TRANSIT="transit",window.BMAP_PANORAMA_POI_INDOOR_SCENE="indoor_scene",window.BMAP_PANORAMA_POI_NONE="none";i.a.module("baiduMap",[]).provider("mapScriptService",function(){var e=null,t=void 0;this.setKey=function(n){t="//api.map.baidu.com/api?v=2.0&ak="+(e=n)+"&callback=baidumapinit",t=location.protocol.indexOf("http")>-1?t+"&s="+("https:"===location.protocol?1:0):"https:"+t+"&s=1"},this.$get=["$rootScope",function(n){"ngInject";return{load:function(){s(e,"ak should be set before use. Read: https://leftstick.github.io/BaiduMapForAngularJS/#!/quickstart");var o=n.loadBaiduMapPromise;return o?o.then(Z):n.loadBaiduMapPromise=new Promise(function(e,n){window.baidumapinit=e,function e(t){var n=document.createElement("script");n.type="text/javascript",n.src=t,n.onerror=function(){Array.prototype.slice.call(document.querySelectorAll("baidu-map .baidu-map-offline")).forEach(function(e){e.style.display="block"}),document.body.removeChild(n),setTimeout(function(){e(t)},3e4)},document.body.appendChild(n)}(t)}).then(Z)}}}]}).component("baiduMap",g).component("marker",P).component("polyline",$).component("circle",E).component("polygon",S).component("heatmap",B).component("control",L).component("overlay",q);var x="baiduMap"}])}); \ No newline at end of file diff --git a/package.json b/package.json index e627666..8e6bf8f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-baidu-map", - "version": "3.2.2", + "version": "3.3.0", "description": "A baidu-map directive for AngularJS", "main": "dist/angular-baidu-map.js", "repository": {