UNPKG

ngx-amap

Version:

[![npm](https://img.shields.io/npm/v/ngx-amap.svg)][npm-badge-url] [![npm](https://img.shields.io/npm/dm/ngx-amap.svg)][npm-badge-url] [![Build Status](https://travis-ci.org/xieziyu/ngx-amap.svg?branch=master)][ci-url]

1,442 lines (1,407 loc) 345 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators')) : typeof define === 'function' && define.amd ? define('ngx-amap', ['exports', '@angular/core', 'rxjs', 'rxjs/operators'], factory) : (global = global || self, factory(global['ngx-amap'] = {}, global.ng.core, global.rxjs, global.rxjs.operators)); }(this, (function (exports, core, rxjs, operators) { 'use strict'; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } function __param(paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } } function __metadata(metadataKey, metadataValue) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); } function __awaiter(thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } function __exportStar(m, exports) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } function __values(o) { var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; if (m) return m.call(o); return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; } function __read(o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; } function __spread() { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; } function __spreadArrays() { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; }; function __await(v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } function __asyncGenerator(thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), i, q = []; return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } } function __asyncDelegator(o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } } function __asyncValues(o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator], i; return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } } function __makeTemplateObject(cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; }; function __importStar(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result.default = mod; return result; } function __importDefault(mod) { return (mod && mod.__esModule) ? mod : { default: mod }; } /** * @fileoverview added by tsickle * Generated from: shared/ngx-amap-config.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @record */ function NgxAmapConfig() { } if (false) { /** @type {?|undefined} */ NgxAmapConfig.prototype.apiKey; /** @type {?|undefined} */ NgxAmapConfig.prototype.apiVersion; /** @type {?|undefined} */ NgxAmapConfig.prototype.uiVersion; /** @type {?|undefined} */ NgxAmapConfig.prototype.protocol; /** @type {?|undefined} */ NgxAmapConfig.prototype.debug; /** @type {?|undefined} */ NgxAmapConfig.prototype.debugTags; } /** @type {?} */ var NGX_AMAP_CONFIG = new core.InjectionToken('NGX_AMAP_CONFIG'); /** * @fileoverview added by tsickle * Generated from: shared/logger/logger.service.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var LoggerService = /** @class */ (function () { function LoggerService() { } /** * @param {...?} args * @return {?} */ LoggerService.prototype.i = /** * @param {...?} args * @return {?} */ function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } console.log.apply(console, __spread(args)); }; /** * @param {...?} args * @return {?} */ LoggerService.prototype.e = /** * @param {...?} args * @return {?} */ function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } console.error.apply(console, __spread(args)); }; /** * @param {...?} args * @return {?} */ LoggerService.prototype.w = /** * @param {...?} args * @return {?} */ function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } console.warn.apply(console, __spread(args)); }; /** * @param {...?} args * @return {?} */ LoggerService.prototype.d = /** * @param {...?} args * @return {?} */ function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } // only stub; }; LoggerService.decorators = [ { type: core.Injectable } ]; /** @nocollapse */ LoggerService.ctorParameters = function () { return []; }; return LoggerService; }()); /** * @fileoverview added by tsickle * Generated from: shared/logger/debug-logger.service.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var DebugLoggerService = /** @class */ (function () { function DebugLoggerService(config) { if (config === void 0) { config = {}; } this.config = config; this.debugTags = []; this.debugAll = true; if (config.debugTags) { if (config.debugTags === '*') { this.debugAll = true; } else { this.debugAll = false; this.debugTags = config.debugTags.split(','); } } } /** * @param {...?} args * @return {?} */ DebugLoggerService.prototype.i = /** * @param {...?} args * @return {?} */ function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } console.log.apply(console, __spread(args)); }; /** * @param {...?} args * @return {?} */ DebugLoggerService.prototype.e = /** * @param {...?} args * @return {?} */ function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } console.error.apply(console, __spread(args)); }; /** * @param {...?} args * @return {?} */ DebugLoggerService.prototype.w = /** * @param {...?} args * @return {?} */ function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } console.warn.apply(console, __spread(args)); }; /** * @param {?} tag * @param {...?} args * @return {?} */ DebugLoggerService.prototype.d = /** * @param {?} tag * @param {...?} args * @return {?} */ function (tag) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } if (this.debugAll || this.debugTags.includes(tag)) { console.log.apply(console, __spread(["[" + tag + "]"], args)); } }; DebugLoggerService.decorators = [ { type: core.Injectable } ]; /** @nocollapse */ DebugLoggerService.ctorParameters = function () { return [ { type: undefined, decorators: [{ type: core.Inject, args: [NGX_AMAP_CONFIG,] }] } ]; }; return DebugLoggerService; }()); if (false) { /** @type {?} */ DebugLoggerService.prototype.debugTags; /** @type {?} */ DebugLoggerService.prototype.debugAll; /** * @type {?} * @private */ DebugLoggerService.prototype.config; } /** * @fileoverview added by tsickle * Generated from: shared/amap-loader.service.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ var TAG = 'AMapLoader'; var AMapLoaderService = /** @class */ (function () { function AMapLoaderService(config, logger) { if (config === void 0) { config = {}; } this.config = config; this.logger = logger; this.defaultProtocol = 'https'; this.defaultVersion = '1.4.15'; this.defaultUIVersion = '1.0.11'; this.config = config || {}; } /** * @return {?} */ AMapLoaderService.prototype.load = /** * @return {?} */ function () { var _this = this; if (this.loading$) { return this.loading$.asObservable(); } this.logger.d(TAG, 'loading AMap API ...'); this.loading$ = new rxjs.ReplaySubject(); /** @type {?} */ var callbackName = '_NgxAmapAPILoader'; /** @type {?} */ var script = document.createElement('script'); script.type = 'text/javascript'; script.async = true; script.defer = true; script.src = this.getSrcFromConfig(callbackName); script.onerror = (/** * @param {?} err * @return {?} */ function (err) { _this.logger.e('failed to load AMap API.'); _this.loading$.error(err); }); window[callbackName] = (/** * @return {?} */ function () { _this.logger.d(TAG, 'loading AMap API COMPLETE'); _this.loading$.next(); _this.loading$.complete(); }); document.body.appendChild(script); return this.loading$.asObservable(); }; /** * @return {?} */ AMapLoaderService.prototype.loadUI = /** * @return {?} */ function () { var _this = this; if (this.uiLoading$) { return this.uiLoading$.asObservable(); } this.logger.d(TAG, 'loading AMap UI ...'); this.uiLoading$ = new rxjs.ReplaySubject(); /** @type {?} */ var uiScript = document.createElement('script'); uiScript.type = 'text/javascript'; uiScript.async = true; uiScript.defer = true; uiScript.src = this.getUISrcFromConfig(); uiScript.onerror = (/** * @param {?} err * @return {?} */ function (err) { _this.logger.e('failed to load AMap API.'); }); uiScript.onload = (/** * @return {?} */ function () { // tslint:disable-next-line: no-string-literal window['initAMapUI'](); _this.logger.d(TAG, 'loading AMap UI COMPLETE'); _this.uiLoading$.next(); _this.uiLoading$.complete(); }); document.body.appendChild(uiScript); return this.uiLoading$.asObservable(); }; /** * @private * @param {?} callbackName * @return {?} */ AMapLoaderService.prototype.getSrcFromConfig = /** * @private * @param {?} callbackName * @return {?} */ function (callbackName) { /** @type {?} */ var urlBase = (this.config.protocol || this.defaultProtocol) + "://webapi.amap.com/maps"; /** @type {?} */ var queryParams = { v: this.config.apiVersion || this.defaultVersion, callback: callbackName, key: this.config.apiKey, }; /** @type {?} */ var params = Object.keys(queryParams) .filter((/** * @param {?} k * @return {?} */ function (k) { return queryParams[k] != null; })) .filter((/** * @param {?} k * @return {?} */ function (k) { // remove empty arrays return (!Array.isArray(queryParams[k]) || (Array.isArray(queryParams[k]) && queryParams[k].length > 0)); })) .map((/** * @param {?} k * @return {?} */ function (k) { // join arrays as comma seperated strings /** @type {?} */ var i = queryParams[k]; if (Array.isArray(i)) { return { key: k, value: i.join(',') }; } return { key: k, value: queryParams[k] }; })) .map((/** * @param {?} entry * @return {?} */ function (entry) { return entry.key + "=" + entry.value; })) .join('&'); return urlBase + "?" + params; }; /** * @private * @return {?} */ AMapLoaderService.prototype.getUISrcFromConfig = /** * @private * @return {?} */ function () { // tslint:disable-next-line: max-line-length /** @type {?} */ var urlBase = (this.config.protocol || this.defaultProtocol) + "://webapi.amap.com/ui/1.0/main-async.js?v=" + (this.config.uiVersion || this.defaultUIVersion); return urlBase; }; AMapLoaderService.decorators = [ { type: core.Injectable } ]; /** @nocollapse */ AMapLoaderService.ctorParameters = function () { return [ { type: undefined, decorators: [{ type: core.Inject, args: [NGX_AMAP_CONFIG,] }] }, { type: LoggerService } ]; }; return AMapLoaderService; }()); if (false) { /** * @type {?} * @private */ AMapLoaderService.prototype.defaultProtocol; /** * @type {?} * @private */ AMapLoaderService.prototype.defaultVersion; /** * @type {?} * @private */ AMapLoaderService.prototype.defaultUIVersion; /** * @type {?} * @private */ AMapLoaderService.prototype.loading$; /** * @type {?} * @private */ AMapLoaderService.prototype.uiLoading$; /** * @type {?} * @private */ AMapLoaderService.prototype.config; /** * @type {?} * @private */ AMapLoaderService.prototype.logger; } /** * @fileoverview added by tsickle * Generated from: shared/amap.service.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ var TAG$1 = 'AMap'; var AMapService = /** @class */ (function () { function AMapService(loader, logger, ngZone) { this.loader = loader; this.logger = logger; this.ngZone = ngZone; this.map$ = new rxjs.ReplaySubject(); } /** * 获取地图对象 AMap.Map */ /** * 获取地图对象 AMap.Map * @return {?} */ AMapService.prototype.get = /** * 获取地图对象 AMap.Map * @return {?} */ function () { return this.map$.asObservable(); }; /** * 创建地图对象 AMap.Map * @param container 地图容器的DOM元素 * @param options 选项 */ /** * 创建地图对象 AMap.Map * @param {?} container 地图容器的DOM元素 * @param {?} options 选项 * @return {?} */ AMapService.prototype.create = /** * 创建地图对象 AMap.Map * @param {?} container 地图容器的DOM元素 * @param {?} options 选项 * @return {?} */ function (container, options) { var _this = this; return this.loader.load().pipe(operators.map((/** * @return {?} */ function () { _this.map = _this.ngZone.runOutsideAngular((/** * @return {?} */ function () { return new AMap.Map(container, options); })); _this.logger.d(TAG$1, 'new map created.'); _this.map$.next(_this.map); _this.map$.complete(); return _this.map; }))); }; /** * 销毁地图对象 */ /** * 销毁地图对象 * @return {?} */ AMapService.prototype.destroy = /** * 销毁地图对象 * @return {?} */ function () { var _this = this; this.get().subscribe((/** * @param {?} m * @return {?} */ function (m) { m.destroy(); _this.logger.d(TAG$1, 'map destroyed.'); _this.map = null; })); }; AMapService.decorators = [ { type: core.Injectable } ]; /** @nocollapse */ AMapService.ctorParameters = function () { return [ { type: AMapLoaderService }, { type: LoggerService }, { type: core.NgZone } ]; }; return AMapService; }()); if (false) { /** * @type {?} * @private */ AMapService.prototype.map; /** * @type {?} * @private */ AMapService.prototype.map$; /** * @type {?} * @private */ AMapService.prototype.loader; /** * @type {?} * @private */ AMapService.prototype.logger; /** * @type {?} * @private */ AMapService.prototype.ngZone; } /** * @fileoverview added by tsickle * Generated from: shared/event-binder.service.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ var TAG$2 = 'EventBinder'; var EventBinderService = /** @class */ (function () { function EventBinderService(logger, ngZone) { this.logger = logger; this.ngZone = ngZone; } /** * 注册事件 * @param eventName 事件名 */ /** * 注册事件 * @template T * @param {?} target * @param {?} eventName 事件名 * @return {?} */ EventBinderService.prototype.bindEvent = /** * 注册事件 * @template T * @param {?} target * @param {?} eventName 事件名 * @return {?} */ function (target, eventName) { var _this = this; return (/** @type {?} */ (target.pipe(operators.switchMap((/** * @param {?} t * @return {?} */ function (t) { return new rxjs.Observable((/** * @param {?} observer * @return {?} */ function (observer) { /** @type {?} */ var handler = AMap.event.addListener(t, eventName, (/** * @param {?} e * @return {?} */ function (e) { _this.ngZone.run((/** * @return {?} */ function () { return observer.next(e); })); }), _this); _this.logger.d(TAG$2, "subscribed event: " + eventName); return (/** * @return {?} */ function () { AMap.event.removeListener(handler); _this.logger.d(TAG$2, "unsubscribed event: " + eventName); eventName = null; handler = null; }); })); }))))); }; EventBinderService.decorators = [ { type: core.Injectable } ]; /** @nocollapse */ EventBinderService.ctorParameters = function () { return [ { type: LoggerService }, { type: core.NgZone } ]; }; return EventBinderService; }()); if (false) { /** * @type {?} * @private */ EventBinderService.prototype.logger; /** * @type {?} * @private */ EventBinderService.prototype.ngZone; } /** * @fileoverview added by tsickle * Generated from: shared/plugin-loader.service.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ var TAG$3 = 'PluginLoader'; var PluginLoaderService = /** @class */ (function () { function PluginLoaderService(amap, logger) { this.amap = amap; this.logger = logger; this.state = new Map(); } /** * @param {?} name * @return {?} */ PluginLoaderService.prototype.load = /** * @param {?} name * @return {?} */ function (name) { var _this = this; /** @type {?} */ var pKey = ''; if (Array.isArray(name)) { pKey = name.join(','); } else { pKey = name; } if (this.state.has(pKey)) { return this.state.get(pKey).asObservable(); } this.logger.d(TAG$3, 'loading plugin:', pKey, '...'); return this.amap.get().pipe(operators.switchMap((/** * @param {?} m * @return {?} */ function (m) { /** @type {?} */ var loading$ = new rxjs.ReplaySubject(1); m.plugin(name, (/** * @return {?} */ function () { _this.logger.d(TAG$3, 'loading plugin:', pKey, 'COMPLETE'); loading$.next(); loading$.complete(); })); _this.state.set(pKey, loading$); return loading$.asObservable(); }))); }; PluginLoaderService.decorators = [ { type: core.Injectable } ]; /** @nocollapse */ PluginLoaderService.ctorParameters = function () { return [ { type: AMapService }, { type: LoggerService } ]; }; return PluginLoaderService; }()); if (false) { /** * @type {?} * @private */ PluginLoaderService.prototype.state; /** * @type {?} * @private */ PluginLoaderService.prototype.amap; /** * @type {?} * @private */ PluginLoaderService.prototype.logger; } /** * @fileoverview added by tsickle * Generated from: utils/change-filter.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var ChangeFilter = /** @class */ (function () { function ChangeFilter(changes) { this.changes = changes; } /** * @param {?} changes * @return {?} */ ChangeFilter.of = /** * @param {?} changes * @return {?} */ function (changes) { return new ChangeFilter(changes); }; /** * @template T * @param {?} key * @return {?} */ ChangeFilter.prototype.notEmpty = /** * @template T * @param {?} key * @return {?} */ function (key) { if (this.changes[key]) { /** @type {?} */ var value = this.changes[key].currentValue; if (value !== undefined && value !== null) { return rxjs.of(value); } } return rxjs.EMPTY; }; /** * @template T * @param {?} key * @return {?} */ ChangeFilter.prototype.has = /** * @template T * @param {?} key * @return {?} */ function (key) { if (this.changes[key]) { /** @type {?} */ var value = this.changes[key].currentValue; return rxjs.of(value); } return rxjs.EMPTY; }; return ChangeFilter; }()); if (false) { /** * @type {?} * @private */ ChangeFilter.prototype.changes; } /** * @fileoverview added by tsickle * Generated from: utils/get-options.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @template T * @param {?} component * @param {?} keys * @return {?} */ function getOptions(component, keys) { /** @type {?} */ var options = {}; keys.forEach((/** * @param {?} key * @return {?} */ function (key) { if (component[key] !== undefined && component[key] !== null) { options[key] = component[key]; } })); return options; } /** * @fileoverview added by tsickle * Generated from: utils/index.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * Generated from: components/ngx-amap/ngx-amap.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ var TAG$4 = 'ngx-amap'; /** @type {?} */ var ALL_OPTIONS = [ 'view', 'layers', 'zoom', 'center', 'labelzIndex', 'zooms', 'lang', 'defaultCursor', 'crs', 'animateEnable', 'isHotspot', 'defaultLayer', 'rotateEnable', 'resizeEnable', 'showIndoorMap', 'indoorMap', 'expandZoomRange', 'dragEnable', 'zoomEnable', 'doubleClickZoom', 'keyboardEnable', 'jogEnable', 'scrollWheel', 'touchZoom', 'touchZoomCenter', 'mapStyle', 'features', 'showBuildingBlock', 'viewMode', 'pitch', 'pitchEnable', 'buildingAnimation', 'skyColor', 'preloadMode', 'mask', 'maxPitch', 'rotation', 'forceVector', 'gridMapForeign', 'vectorMapForeign', ]; var NgxAmapComponent = /** @class */ (function () { function NgxAmapComponent(el, amap, pluginLoader, logger, binder, ngZone) { this.el = el; this.amap = amap; this.pluginLoader = pluginLoader; this.logger = logger; this.binder = binder; this.ngZone = ngZone; // ---- Map Events ---- this.naReady = new core.EventEmitter(); this.naPluginsLoaded = new core.EventEmitter(); this.inited = false; /** @type {?} */ var m = this.amap.get(); this.naComplete = this.binder.bindEvent(m, 'complete'); this.naClick = this.binder.bindEvent(m, 'click'); this.naDblClick = this.binder.bindEvent(m, 'dblclick'); this.naRightClick = this.binder.bindEvent(m, 'rightclick'); this.naMouseMove = this.binder.bindEvent(m, 'mousemove'); this.naMouseOver = this.binder.bindEvent(m, 'mouseover'); this.naMouseWheel = this.binder.bindEvent(m, 'mousewheel'); this.naMouseUp = this.binder.bindEvent(m, 'mouseup'); this.naMouseOut = this.binder.bindEvent(m, 'mouseout'); this.naMouseDown = this.binder.bindEvent(m, 'mousedown'); this.naTouchStart = this.binder.bindEvent(m, 'touchstart'); this.naTouchMove = this.binder.bindEvent(m, 'touchmove'); this.naTouchEnd = this.binder.bindEvent(m, 'touchend'); this.naHotspotClick = this.binder.bindEvent(m, 'hotspotclick'); this.naHotspotOver = this.binder.bindEvent(m, 'hotspotover'); this.naHotspotOut = this.binder.bindEvent(m, 'hotspotout'); this.naDragStart = this.binder.bindEvent(m, 'dragstart'); this.naDragging = this.binder.bindEvent(m, 'dragging'); this.naDragEnd = this.binder.bindEvent(m, 'dragend'); this.naResize = this.binder.bindEvent(m, 'resize'); this.naZoomStart = this.binder.bindEvent(m, 'zoomstart'); this.naZoomEnd = this.binder.bindEvent(m, 'zoomend'); this.naZoomChange = this.binder.bindEvent(m, 'zoomchange'); this.naMoveStart = this.binder.bindEvent(m, 'movestart'); this.naMoveEnd = this.binder.bindEvent(m, 'moveend'); this.naMove = this.binder.bindEvent(m, 'mapmove'); } /** * @return {?} */ NgxAmapComponent.prototype.ngOnInit = /** * @return {?} */ function () { var _this = this; this.logger.d(TAG$4, 'initializing ...'); /** @type {?} */ var container = this.el.nativeElement.querySelector('div.ngx-amap-container-inner'); /** @type {?} */ var options = getOptions(this, ALL_OPTIONS); this.logger.d(TAG$4, 'options:', options); this.amap.create(container, options).subscribe((/** * @param {?} amap * @return {?} */ function (amap) { _this.logger.d(TAG$4, 'map is ready.'); _this.ngZone.run((/** * @return {?} */ function () { return _this.naReady.emit(amap); })); })); this.inited = true; }; /** * @return {?} */ NgxAmapComponent.prototype.ngOnDestroy = /** * @return {?} */ function () { this.amap.destroy(); }; /** * @param {?} changes * @return {?} */ NgxAmapComponent.prototype.ngOnChanges = /** * @param {?} changes * @return {?} */ function (changes) { var _this = this; /** @type {?} */ var filter = ChangeFilter.of(changes); /** @type {?} */ var amap = this.get(); if (this.inited) { rxjs.zip(filter.has('zoom'), amap).subscribe((/** * @param {?} __0 * @return {?} */ function (_a) { var _b = __read(_a, 2), v = _b[0], m = _b[1]; _this.logger.d(TAG$4, 'setZoom:', v); m.setZoom(v); })); rxjs.zip(filter.has('center'), amap).subscribe((/** * @param {?} __0 * @return {?} */ function (_a) { var _b = __read(_a, 2), v = _b[0], m = _b[1]; _this.logger.d(TAG$4, 'setCenter:', v); m.setCenter(v); })); } // Not included in OPTIONS rxjs.zip(filter.has('city'), amap).subscribe((/** * @param {?} __0 * @return {?} */ function (_a) { var _b = __read(_a, 2), v = _b[0], m = _b[1]; m.setCity(v, (/** * @return {?} */ function () { _this.logger.d(TAG$4, 'setCity:', v); })); })); rxjs.zip(filter.notEmpty('plugins'), amap).subscribe((/** * @param {?} __0 * @return {?} */ function (_a) { var _b = __read(_a, 2), v = _b[0], m = _b[1]; _this.pluginLoader.load(v).subscribe((/** * @return {?} */ function () { _this.logger.d(TAG$4, 'plugins loaded.'); _this.ngZone.run((/** * @return {?} */ function () { return _this.naPluginsLoaded.emit(m); })); })); })); }; /** * 获取已创建的 AMap.Map 对象 */ /** * 获取已创建的 AMap.Map 对象 * @return {?} */ NgxAmapComponent.prototype.get = /** * 获取已创建的 AMap.Map 对象 * @return {?} */ function () { return this.amap.get(); }; NgxAmapComponent.decorators = [ { type: core.Component, args: [{ selector: 'ngx-amap', exportAs: 'amap', template: "<div class='ngx-amap-container-inner'></div>\n<div class='ngx-amap-content'>\n <ng-content></ng-content>\n</div>", providers: [AMapService, PluginLoaderService], styles: [".ngx-amap-container-inner{width:inherit;height:inherit}.ngx-amap-content{display:none}"] }] } ]; /** @nocollapse */ NgxAmapComponent.ctorParameters = function () { return [ { type: core.ElementRef }, { type: AMapService }, { type: PluginLoaderService }, { type: LoggerService }, { type: EventBinderService }, { type: core.NgZone } ]; }; NgxAmapComponent.propDecorators = { view: [{ type: core.Input }], layers: [{ type: core.Input }], zoom: [{ type: core.Input }], center: [{ type: core.Input }], labelzIndex: [{ type: core.Input }], zooms: [{ type: core.Input }], lang: [{ type: core.Input }], defaultCursor: [{ type: core.Input }], crs: [{ type: core.Input }], animateEnable: [{ type: core.Input }], isHotspot: [{ type: core.Input }], defaultLayer: [{ type: core.Input }], rotateEnable: [{ type: core.Input }], resizeEnable: [{ type: core.Input }], showIndoorMap: [{ type: core.Input }], indoorMap: [{ type: core.Input }], expandZoomRange: [{ type: core.Input }], dragEnable: [{ type: core.Input }], zoomEnable: [{ type: core.Input }], doubleClickZoom: [{ type: core.Input }], keyboardEnable: [{ type: core.Input }], jogEnable: [{ type: core.Input }], scrollWheel: [{ type: core.Input }], touchZoom: [{ type: core.Input }], touchZoomCenter: [{ type: core.Input }], mapStyle: [{ type: core.Input }], features: [{ type: core.Input }], showBuildingBlock: [{ type: core.Input }], viewMode: [{ type: core.Input }], pitch: [{ type: core.Input }], pitchEnable: [{ type: core.Input }], buildingAnimation: [{ type: core.Input }], skyColor: [{ type: core.Input }], preloadMode: [{ type: core.Input }], mask: [{ type: core.Input }], maxPitch: [{ type: core.Input }], rotation: [{ type: core.Input }], forceVector: [{ type: core.Input }], gridMapForeign: [{ type: core.Input }], vectorMapForeign: [{ type: core.Input }], city: [{ type: core.Input }], name: [{ type: core.Input }], plugins: [{ type: core.Input }], naReady: [{ type: core.Output }], naComplete: [{ type: core.Output }], naClick: [{ type: core.Output }], naDblClick: [{ type: core.Output }], naRightClick: [{ type: core.Output }], naMouseMove: [{ type: core.Output }], naMouseOver: [{ type: core.Output }], naMouseWheel: [{ type: core.Output }], naMouseUp: [{ type: core.Output }], naMouseOut: [{ type: core.Output }], naMouseDown: [{ type: core.Output }], naTouchStart: [{ type: core.Output }], naTouchMove: [{ type: core.Output }], naTouchEnd: [{ type: core.Output }], naHotspotClick: [{ type: core.Output }], naHotspotOver: [{ type: core.Output }], naHotspotOut: [{ type: core.Output }], naDragStart: [{ type: core.Output }], naDragging: [{ type: core.Output }], naDragEnd: [{ type: core.Output }], naResize: [{ type: core.Output }], naZoomStart: [{ type: core.Output }], naZoomEnd: [{ type: core.Output }], naZoomChange: [{ type: core.Output }], naMoveStart: [{ type: core.Output }], naMoveEnd: [{ type: core.Output }], naMove: [{ type: core.Output }], naPluginsLoaded: [{ type: core.Output }] }; return NgxAmapComponent; }()); if (false) { /** * 地图视口,用于控制影响地图静态显示的属性 * @type {?} */ NgxAmapComponent.prototype.view; /** * 地图图层数组,数组可以是图层 中的一个或多个,默认为普通二维地图 * @type {?} */ NgxAmapComponent.prototype.layers; /** * 地图显示的缩放级别 * @type {?} */ NgxAmapComponent.prototype.zoom; /** * 地图中心点坐标值 * @type {?} */ NgxAmapComponent.prototype.center; /** * 地图标注显示顺序 * @type {?} */ NgxAmapComponent.prototype.labelzIndex; /** * 地图显示的缩放级别范围 * @type {?} */ NgxAmapComponent.prototype.zooms; /** * 地图语言类型 * @type {?} */ NgxAmapComponent.prototype.lang; /** * 地图默认鼠标样式 * @type {?} */ NgxAmapComponent.prototype.defaultCursor; /** * 地图显示的参考坐标系 * @type {?} */ NgxAmapComponent.prototype.crs; /** * 地图平移过程中是否使用动画 * @type {?} */ NgxAmapComponent.prototype.animateEnable; /** * 是否开启地图热点和标注的hover效果 * @type {?} */ NgxAmapComponent.prototype.isHotspot; /** * 当前地图中默认显示的图层 * @type {?} */ NgxAmapComponent.prototype.defaultLayer; /** * 地图是否可旋转 * @type {?} */ NgxAmapComponent.prototype.rotateEnable; /** * 是否监控地图容器尺寸变化 * @type {?} */ NgxAmapComponent.prototype.resizeEnable; /** * 是否在有矢量底图的时候自动展示室内地图 * @type {?} */ NgxAmapComponent.prototype.showIndoorMap; /** * 在展示矢量图的时候自动展示室内地图图层 * @type {?} */ NgxAmapComponent.prototype.indoorMap; /** * 是否支持可以扩展最大缩放级别 * @type {?} */ NgxAmapComponent.prototype.expandZoomRange; /** * 地图是否可通过鼠标拖拽平移 * @type {?} */ NgxAmapComponent.prototype.dragEnable; /** * 地图是否可缩放 * @type {?} */ NgxAmapComponent.prototype.zoomEnable; /** * 地图是否可通过双击鼠标放大地图 * @type {?} */ NgxAmapComponent.prototype.doubleClickZoom; /** * 地图是否可通过键盘控制 * @type {?} */ NgxAmapComponent.prototype.keyboardEnable; /** * 地图是否使用缓动效果 * @type {?} */ NgxAmapComponent.prototype.jogEnable; /** * 地图是否可通过鼠标滚轮缩放浏览 * @type {?} */ NgxAmapComponent.prototype.scrollWheel; /** * 地图在移动终端上是否可通过多点触控缩放浏览地图 * @type {?} */ NgxAmapComponent.prototype.touchZ