ngx-amap
Version:
[][npm-badge-url] [][npm-badge-url] [][ci-url]
1,909 lines (1,890 loc) • 243 kB
JavaScript
import { InjectionToken, Injectable, Inject, NgZone, EventEmitter, Component, ElementRef, Input, Output, ɵɵdefineInjectable, ɵɵinject, QueryList, Directive, ContentChildren, NgModule } from '@angular/core';
import { ReplaySubject, Observable, of, EMPTY, zip, combineLatest } from 'rxjs';
import { map, switchMap, switchMapTo } from 'rxjs/operators';
/**
* @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 {?} */
const NGX_AMAP_CONFIG = new 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
*/
class LoggerService {
constructor() { }
/**
* @param {...?} args
* @return {?}
*/
i(...args) {
console.log(...args);
}
/**
* @param {...?} args
* @return {?}
*/
e(...args) {
console.error(...args);
}
/**
* @param {...?} args
* @return {?}
*/
w(...args) {
console.warn(...args);
}
/**
* @param {...?} args
* @return {?}
*/
d(...args) {
// only stub;
}
}
LoggerService.decorators = [
{ type: Injectable }
];
/** @nocollapse */
LoggerService.ctorParameters = () => [];
/**
* @fileoverview added by tsickle
* Generated from: shared/logger/debug-logger.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class DebugLoggerService {
/**
* @param {?=} config
*/
constructor(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 {?}
*/
i(...args) {
console.log(...args);
}
/**
* @param {...?} args
* @return {?}
*/
e(...args) {
console.error(...args);
}
/**
* @param {...?} args
* @return {?}
*/
w(...args) {
console.warn(...args);
}
/**
* @param {?} tag
* @param {...?} args
* @return {?}
*/
d(tag, ...args) {
if (this.debugAll || this.debugTags.includes(tag)) {
console.log(`[${tag}]`, ...args);
}
}
}
DebugLoggerService.decorators = [
{ type: Injectable }
];
/** @nocollapse */
DebugLoggerService.ctorParameters = () => [
{ type: undefined, decorators: [{ type: Inject, args: [NGX_AMAP_CONFIG,] }] }
];
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 {?} */
const TAG = 'AMapLoader';
class AMapLoaderService {
/**
* @param {?=} config
* @param {?=} logger
*/
constructor(config = {}, logger) {
this.config = config;
this.logger = logger;
this.defaultProtocol = 'https';
this.defaultVersion = '1.4.15';
this.defaultUIVersion = '1.0.11';
this.config = config || {};
}
/**
* @return {?}
*/
load() {
if (this.loading$) {
return this.loading$.asObservable();
}
this.logger.d(TAG, 'loading AMap API ...');
this.loading$ = new ReplaySubject();
/** @type {?} */
const callbackName = '_NgxAmapAPILoader';
/** @type {?} */
const script = document.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.defer = true;
script.src = this.getSrcFromConfig(callbackName);
script.onerror = (/**
* @param {?} err
* @return {?}
*/
(err) => {
this.logger.e('failed to load AMap API.');
this.loading$.error(err);
});
window[callbackName] = (/**
* @return {?}
*/
() => {
this.logger.d(TAG, 'loading AMap API COMPLETE');
this.loading$.next();
this.loading$.complete();
});
document.body.appendChild(script);
return this.loading$.asObservable();
}
/**
* @return {?}
*/
loadUI() {
if (this.uiLoading$) {
return this.uiLoading$.asObservable();
}
this.logger.d(TAG, 'loading AMap UI ...');
this.uiLoading$ = new ReplaySubject();
/** @type {?} */
const uiScript = document.createElement('script');
uiScript.type = 'text/javascript';
uiScript.async = true;
uiScript.defer = true;
uiScript.src = this.getUISrcFromConfig();
uiScript.onerror = (/**
* @param {?} err
* @return {?}
*/
(err) => {
this.logger.e('failed to load AMap API.');
});
uiScript.onload = (/**
* @return {?}
*/
() => {
// 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 {?}
*/
getSrcFromConfig(callbackName) {
/** @type {?} */
const urlBase = `${this.config.protocol || this.defaultProtocol}://webapi.amap.com/maps`;
/** @type {?} */
const queryParams = {
v: this.config.apiVersion || this.defaultVersion,
callback: callbackName,
key: this.config.apiKey,
};
/** @type {?} */
const params = Object.keys(queryParams)
.filter((/**
* @param {?} k
* @return {?}
*/
(k) => queryParams[k] != null))
.filter((/**
* @param {?} k
* @return {?}
*/
(k) => {
// remove empty arrays
return (!Array.isArray(queryParams[k]) ||
(Array.isArray(queryParams[k]) && queryParams[k].length > 0));
}))
.map((/**
* @param {?} k
* @return {?}
*/
(k) => {
// join arrays as comma seperated strings
/** @type {?} */
const i = queryParams[k];
if (Array.isArray(i)) {
return { key: k, value: i.join(',') };
}
return { key: k, value: queryParams[k] };
}))
.map((/**
* @param {?} entry
* @return {?}
*/
(entry) => `${entry.key}=${entry.value}`))
.join('&');
return `${urlBase}?${params}`;
}
/**
* @private
* @return {?}
*/
getUISrcFromConfig() {
// tslint:disable-next-line: max-line-length
/** @type {?} */
const 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: Injectable }
];
/** @nocollapse */
AMapLoaderService.ctorParameters = () => [
{ type: undefined, decorators: [{ type: Inject, args: [NGX_AMAP_CONFIG,] }] },
{ type: LoggerService }
];
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 {?} */
const TAG$1 = 'AMap';
class AMapService {
/**
* @param {?} loader
* @param {?} logger
* @param {?} ngZone
*/
constructor(loader, logger, ngZone) {
this.loader = loader;
this.logger = logger;
this.ngZone = ngZone;
this.map$ = new ReplaySubject();
}
/**
* 获取地图对象 AMap.Map
* @return {?}
*/
get() {
return this.map$.asObservable();
}
/**
* 创建地图对象 AMap.Map
* @param {?} container 地图容器的DOM元素
* @param {?} options 选项
* @return {?}
*/
create(container, options) {
return this.loader.load().pipe(map((/**
* @return {?}
*/
() => {
this.map = this.ngZone.runOutsideAngular((/**
* @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 {?}
*/
destroy() {
this.get().subscribe((/**
* @param {?} m
* @return {?}
*/
m => {
m.destroy();
this.logger.d(TAG$1, 'map destroyed.');
this.map = null;
}));
}
}
AMapService.decorators = [
{ type: Injectable }
];
/** @nocollapse */
AMapService.ctorParameters = () => [
{ type: AMapLoaderService },
{ type: LoggerService },
{ type: NgZone }
];
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 {?} */
const TAG$2 = 'EventBinder';
class EventBinderService {
/**
* @param {?} logger
* @param {?} ngZone
*/
constructor(logger, ngZone) {
this.logger = logger;
this.ngZone = ngZone;
}
/**
* 注册事件
* @template T
* @param {?} target
* @param {?} eventName 事件名
* @return {?}
*/
bindEvent(target, eventName) {
return (/** @type {?} */ (target.pipe(switchMap((/**
* @param {?} t
* @return {?}
*/
(t) => new Observable((/**
* @param {?} observer
* @return {?}
*/
observer => {
/** @type {?} */
let handler = AMap.event.addListener(t, eventName, (/**
* @param {?} e
* @return {?}
*/
e => {
this.ngZone.run((/**
* @return {?}
*/
() => observer.next(e)));
}), this);
this.logger.d(TAG$2, `subscribed event: ${eventName}`);
return (/**
* @return {?}
*/
() => {
AMap.event.removeListener(handler);
this.logger.d(TAG$2, `unsubscribed event: ${eventName}`);
eventName = null;
handler = null;
});
})))))));
}
}
EventBinderService.decorators = [
{ type: Injectable }
];
/** @nocollapse */
EventBinderService.ctorParameters = () => [
{ type: LoggerService },
{ type: NgZone }
];
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 {?} */
const TAG$3 = 'PluginLoader';
class PluginLoaderService {
/**
* @param {?} amap
* @param {?} logger
*/
constructor(amap, logger) {
this.amap = amap;
this.logger = logger;
this.state = new Map();
}
/**
* @param {?} name
* @return {?}
*/
load(name) {
/** @type {?} */
let 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(switchMap((/**
* @param {?} m
* @return {?}
*/
m => {
/** @type {?} */
const loading$ = new ReplaySubject(1);
m.plugin(name, (/**
* @return {?}
*/
() => {
this.logger.d(TAG$3, 'loading plugin:', pKey, 'COMPLETE');
loading$.next();
loading$.complete();
}));
this.state.set(pKey, loading$);
return loading$.asObservable();
})));
}
}
PluginLoaderService.decorators = [
{ type: Injectable }
];
/** @nocollapse */
PluginLoaderService.ctorParameters = () => [
{ type: AMapService },
{ type: LoggerService }
];
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
*/
class ChangeFilter {
/**
* @param {?} changes
*/
constructor(changes) {
this.changes = changes;
}
/**
* @param {?} changes
* @return {?}
*/
static of(changes) {
return new ChangeFilter(changes);
}
/**
* @template T
* @param {?} key
* @return {?}
*/
notEmpty(key) {
if (this.changes[key]) {
/** @type {?} */
const value = this.changes[key].currentValue;
if (value !== undefined && value !== null) {
return of(value);
}
}
return EMPTY;
}
/**
* @template T
* @param {?} key
* @return {?}
*/
has(key) {
if (this.changes[key]) {
/** @type {?} */
const value = this.changes[key].currentValue;
return of(value);
}
return EMPTY;
}
}
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 {?} */
const options = {};
keys.forEach((/**
* @param {?} key
* @return {?}
*/
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 {?} */
const TAG$4 = 'ngx-amap';
/** @type {?} */
const 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',
];
class NgxAmapComponent {
/**
* @param {?} el
* @param {?} amap
* @param {?} pluginLoader
* @param {?} logger
* @param {?} binder
* @param {?} ngZone
*/
constructor(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 EventEmitter();
this.naPluginsLoaded = new EventEmitter();
this.inited = false;
/** @type {?} */
const 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 {?}
*/
ngOnInit() {
this.logger.d(TAG$4, 'initializing ...');
/** @type {?} */
const container = this.el.nativeElement.querySelector('div.ngx-amap-container-inner');
/** @type {?} */
const options = getOptions(this, ALL_OPTIONS);
this.logger.d(TAG$4, 'options:', options);
this.amap.create(container, options).subscribe((/**
* @param {?} amap
* @return {?}
*/
amap => {
this.logger.d(TAG$4, 'map is ready.');
this.ngZone.run((/**
* @return {?}
*/
() => this.naReady.emit(amap)));
}));
this.inited = true;
}
/**
* @return {?}
*/
ngOnDestroy() {
this.amap.destroy();
}
/**
* @param {?} changes
* @return {?}
*/
ngOnChanges(changes) {
/** @type {?} */
const filter = ChangeFilter.of(changes);
/** @type {?} */
const amap = this.get();
if (this.inited) {
zip(filter.has('zoom'), amap).subscribe((/**
* @param {?} __0
* @return {?}
*/
([v, m]) => {
this.logger.d(TAG$4, 'setZoom:', v);
m.setZoom(v);
}));
zip(filter.has('center'), amap).subscribe((/**
* @param {?} __0
* @return {?}
*/
([v, m]) => {
this.logger.d(TAG$4, 'setCenter:', v);
m.setCenter(v);
}));
}
// Not included in OPTIONS
zip(filter.has('city'), amap).subscribe((/**
* @param {?} __0
* @return {?}
*/
([v, m]) => {
m.setCity(v, (/**
* @return {?}
*/
() => {
this.logger.d(TAG$4, 'setCity:', v);
}));
}));
zip(filter.notEmpty('plugins'), amap).subscribe((/**
* @param {?} __0
* @return {?}
*/
([v, m]) => {
this.pluginLoader.load(v).subscribe((/**
* @return {?}
*/
() => {
this.logger.d(TAG$4, 'plugins loaded.');
this.ngZone.run((/**
* @return {?}
*/
() => this.naPluginsLoaded.emit(m)));
}));
}));
}
/**
* 获取已创建的 AMap.Map 对象
* @return {?}
*/
get() {
return this.amap.get();
}
}
NgxAmapComponent.decorators = [
{ type: 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 = () => [
{ type: ElementRef },
{ type: AMapService },
{ type: PluginLoaderService },
{ type: LoggerService },
{ type: EventBinderService },
{ type: NgZone }
];
NgxAmapComponent.propDecorators = {
view: [{ type: Input }],
layers: [{ type: Input }],
zoom: [{ type: Input }],
center: [{ type: Input }],
labelzIndex: [{ type: Input }],
zooms: [{ type: Input }],
lang: [{ type: Input }],
defaultCursor: [{ type: Input }],
crs: [{ type: Input }],
animateEnable: [{ type: Input }],
isHotspot: [{ type: Input }],
defaultLayer: [{ type: Input }],
rotateEnable: [{ type: Input }],
resizeEnable: [{ type: Input }],
showIndoorMap: [{ type: Input }],
indoorMap: [{ type: Input }],
expandZoomRange: [{ type: Input }],
dragEnable: [{ type: Input }],
zoomEnable: [{ type: Input }],
doubleClickZoom: [{ type: Input }],
keyboardEnable: [{ type: Input }],
jogEnable: [{ type: Input }],
scrollWheel: [{ type: Input }],
touchZoom: [{ type: Input }],
touchZoomCenter: [{ type: Input }],
mapStyle: [{ type: Input }],
features: [{ type: Input }],
showBuildingBlock: [{ type: Input }],
viewMode: [{ type: Input }],
pitch: [{ type: Input }],
pitchEnable: [{ type: Input }],
buildingAnimation: [{ type: Input }],
skyColor: [{ type: Input }],
preloadMode: [{ type: Input }],
mask: [{ type: Input }],
maxPitch: [{ type: Input }],
rotation: [{ type: Input }],
forceVector: [{ type: Input }],
gridMapForeign: [{ type: Input }],
vectorMapForeign: [{ type: Input }],
city: [{ type: Input }],
name: [{ type: Input }],
plugins: [{ type: Input }],
naReady: [{ type: Output }],
naComplete: [{ type: Output }],
naClick: [{ type: Output }],
naDblClick: [{ type: Output }],
naRightClick: [{ type: Output }],
naMouseMove: [{ type: Output }],
naMouseOver: [{ type: Output }],
naMouseWheel: [{ type: Output }],
naMouseUp: [{ type: Output }],
naMouseOut: [{ type: Output }],
naMouseDown: [{ type: Output }],
naTouchStart: [{ type: Output }],
naTouchMove: [{ type: Output }],
naTouchEnd: [{ type: Output }],
naHotspotClick: [{ type: Output }],
naHotspotOver: [{ type: Output }],
naHotspotOut: [{ type: Output }],
naDragStart: [{ type: Output }],
naDragging: [{ type: Output }],
naDragEnd: [{ type: Output }],
naResize: [{ type: Output }],
naZoomStart: [{ type: Output }],
naZoomEnd: [{ type: Output }],
naZoomChange: [{ type: Output }],
naMoveStart: [{ type: Output }],
naMoveEnd: [{ type: Output }],
naMove: [{ type: Output }],
naPluginsLoaded: [{ type: Output }]
};
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.touchZoom;
/**
* 当touchZoomCenter=1的时候,手机端双指缩放的以地图中心为中心,否则默认以双指中间点为中心
* @type {?}
*/
NgxAmapComponent.prototype.touchZoomCenter;
/**
* 设置地图的显示样式
* @type {?}
*/
NgxAmapComponent.prototype.mapStyle;
/**
* 设置地图上显示的元素种类
* @type {?}
*/
NgxAmapComponent.prototype.features;
/**
* 设置地图显示3D楼块效果
* @type {?}
*/
NgxAmapComponent.prototype.showBuildingBlock;
/**
* 视图模式
* @type {?}
*/
NgxAmapComponent.prototype.viewMode;
/**
* 俯仰角度
* @type {?}
*/
NgxAmapComponent.prototype.pitch;
/**
* 是否允许设置俯仰角度
* @type {?}
*/
NgxAmapComponent.prototype.pitchEnable;
/**
* 楼块出现和消失的时候是否显示动画过程
* @type {?}
*/
NgxAmapComponent.prototype.buildingAnimation;
/**
* 调整天空颜色
* @type {?}
*/
NgxAmapComponent.prototype.skyColor;
/**
* 设置地图的预加载模式
* @type {?}
*/
NgxAmapComponent.prototype.preloadMode;
/**
* 为 Map 实例指定掩模的路径,各图层将只显示路径范围内图像
* @type {?}
*/
NgxAmapComponent.prototype.mask;
/** @type {?} */
NgxAmapComponent.prototype.maxPitch;
/** @type {?} */
NgxAmapComponent.prototype.rotation;
/** @type {?} */
NgxAmapComponent.prototype.forceVector;
/** @type {?} */
NgxAmapComponent.prototype.gridMapForeign;
/**
* 额外: 海外⽮量地图样式
* @type {?}
*/
NgxAmapComponent.prototype.vectorMapForeign;
/**
* 额外: 设置城市
* @type {?}
*/
NgxAmapComponent.prototype.city;
/**
* 额外: 设置地图名
* @type {?}
*/
NgxAmapComponent.prototype.name;
/**
* 额外:加载插件
* @type {?}
*/
NgxAmapComponent.prototype.plugins;
/** @type {?} */
NgxAmapComponent.prototype.naReady;
/** @type {?} */
NgxAmapComponent.prototype.naComplete;
/** @type {?} */
NgxAmapComponent.prototype.naClick;
/** @type {?} */
NgxAmapComponent.prototype.naDblClick;
/** @type {?} */
NgxAmapComponent.prototype.naRightClick;
/** @type {?} */
NgxAmapComponent.prototype.naMouseMove;
/** @type {?} */
NgxAmapComponent.prototype.naMouseOver;
/** @type {?} */
NgxAmapComponent.prototype.naMouseWheel;
/** @type {?} */
NgxAmapComponent.prototype.naMouseUp;
/** @type {?} */
NgxAmapComponent.prototype.naMouseOut;
/** @type {?} */
NgxAmapComponent.prototype.naMouseDown;
/** @type {?} */
NgxAmapComponent.prototype.naTouchStart;
/** @type {?} */
NgxAmapComponent.prototype.naTouchMove;
/** @type {?} */
NgxAmapComponent.prototype.naTouchEnd;
/** @type {?} */
NgxAmapComponent.prototype.naHotspotClick;
/** @type {?} */
NgxAmapComponent.prototype.naHotspotOver;
/** @type {?} */
NgxAmapComponent.prototype.naHotspotOut;
/** @type {?} */
NgxAmapComponent.prototype.naDragStart;
/** @type {?} */
NgxAmapComponent.prototype.naDragging;
/** @type {?} */
NgxAmapComponent.prototype.naDragEnd;
/** @type {?} */
NgxAmapComponent.prototype.naResize;
/** @type {?} */
NgxAmapComponent.prototype.naZoomStart;
/** @type {?} */
NgxAmapComponent.prototype.naZoomEnd;
/** @type {?} */
NgxAmapComponent.prototype.naZoomChange;
/** @type {?} */
NgxAmapComponent.prototype.naMoveStart;
/** @type {?} */
NgxAmapComponent.prototype.naMoveEnd;
/** @type {?} */
NgxAmapComponent.prototype.naMove;
/** @type {?} */
NgxAmapComponent.prototype.naPluginsLoaded;
/**
* @type {?}
* @private
*/
NgxAmapComponent.prototype.inited;
/**
* @type {?}
* @private
*/
NgxAmapComponent.prototype.el;
/**
* @type {?}
* @private
*/
NgxAmapComponent.prototype.amap;
/**
* @type {?}
* @private
*/
NgxAmapComponent.prototype.pluginLoader;
/**
* @type {?}
* @private
*/
NgxAmapComponent.prototype.logger;
/**
* @type {?}
* @private
*/
NgxAmapComponent.prototype.binder;
/**
* @type {?}
* @private
*/
NgxAmapComponent.prototype.ngZone;
}
/**
* @fileoverview added by tsickle
* Generated from: directives/amap-marker/amap-marker.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
const TAG$5 = 'AmapMarker';
class AmapMarkerService {
/**
* @param {?} amaps
* @param {?} logger
* @param {?} ngZone
*/
constructor(amaps, logger, ngZone) {
this.amaps = amaps;
this.logger = logger;
this.ngZone = ngZone;
this.marker$ = new ReplaySubject(1);
}
/**
* 获取点标记
* @return {?}
*/
get() {
return this.marker$.asObservable();
}
/**
* 创建点标记 AMap.Marker
* @param {?} options 选项
* @param {?=} addToMap 是否直接加进地图
* @return {?}
*/
create(options, addToMap = true) {
return this.amaps.get().pipe(map((/**
* @param {?} m
* @return {?}
*/
m => {
if (addToMap) {
options.map = m;
}
this.marker = this.ngZone.runOutsideAngular((/**
* @return {?}
*/
() => new AMap.Marker(options)));
this.logger.d(TAG$5, 'new marker created.');
this.marker$.next(this.marker);
this.marker$.complete();
return this.marker;
})));
}
/**
* 销毁点标记
* @return {?}
*/
destroy() {
this.get().subscribe((/**
* @param {?} m
* @return {?}
*/
m => {
m.setMap(null);
this.logger.d(TAG$5, 'marker destroyed.');
this.marker = null;
}));
}
}
AmapMarkerService.decorators = [
{ type: Injectable }
];
/** @nocollapse */
AmapMarkerService.ctorParameters = () => [
{ type: AMapService },
{ type: LoggerService },
{ type: NgZone }
];
if (false) {
/**
* @type {?}
* @private
*/
AmapMarkerService.prototype.marker;
/**
* @type {?}
* @private
*/
AmapMarkerService.prototype.marker$;
/**
* @type {?}
* @private
*/
AmapMarkerService.prototype.amaps;
/**
* @type {?}
* @private
*/
AmapMarkerService.prototype.logger;
/**
* @type {?}
* @private
*/
AmapMarkerService.prototype.ngZone;
}
/**
* @fileoverview added by tsickle
* Generated from: base/amap-overlay.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
const OverlayOptions = ['cursor', 'extData', 'bubble', 'clickable', 'draggable'];
/**
* @template T
*/
class AMapOverlay {
/**
* @param {?} os
* @param {?} binder
*/
constructor(os, binder) {
this.os = os;
this.binder = binder;
/** @type {?} */
const target = os.get();
this.naTouchStart = this.binder.bindEvent(target, 'touchstart');
this.naTouchMove = this.binder.bindEvent(target, 'touchmove');
this.naTouchEnd = this.binder.bindEvent(target, 'touchend');
this.naClick = this.binder.bindEvent(target, 'click');
this.naDblClick = this.binder.bindEvent(target, 'dblclick');
this.naRightClick = this.binder.bindEvent(target, 'rightclick');
this.naMouseOver = this.binder.bindEvent(target, 'mouseover');
this.naMouseUp = this.binder.bindEvent(target, 'mouseup');
this.naMouseOut = this.binder.bindEvent(target, 'mouseout');
this.naMouseDown = this.binder.bindEvent(target, 'mousedown');
}
}
AMapOverlay.propDecorators = {
cursor: [{ type: Input }],
extData: [{ type: Input }],
bubble: [{ type: Input }],
clickable: [{ type: Input }],
draggable: [{ type: Input }],
naTouchStart: [{ type: Output }],
naTouchMove: [{ type: Output }],
naTouchEnd: [{ type: Output }],
naClick: [{ type: Output }],
naDblClick: [{ type: Output }],
naRightClick: [{ type: Output }],
naMouseOver: [{ type: Output }],
naMouseUp: [{ type: Output }],
naMouseOut: [{ type: Output }],
naMouseDown: [{ type: Output }]
};
if (false) {
/**
* 鼠标悬停时的鼠标样式
* @type {?}
*/
AMapOverlay.prototype.cursor;
/**
* 自定义数据
* @type {?}
*/
AMapOverlay.prototype.extData;
/**
* 事件是否穿透到地图
* @type {?}
*/
AMapOverlay.prototype.bubble;
/**
* 是否支持点击
* @type {?}
*/
AMapOverlay.prototype.clickable;
/**
* 是否支持拖拽
* @type {?}
*/
AMapOverlay.prototype.draggable;
/** @type {?} */
AMapOverlay.prototype.naTouchStart;
/** @type {?} */
AMapOverlay.prototype.naTouchMove;
/** @type {?} */
AMapOverlay.prototype.naTouchEnd;
/** @type {?} */
AMapOverlay.prototype.naClick;
/** @type {?} */
AMapOverlay.prototype.naDblClick;
/** @type {?} */
AMapOverlay.prototype.naRightClick;
/** @type {?} */
AMapOverlay.prototype.naMouseOver;
/** @type {?} */
AMapOverlay.prototype.naMouseUp;
/** @type {?} */
AMapOverlay.prototype.naMouseOut;
/** @type {?} */
AMapOverlay.prototype.naMouseDown;
/**
* @type {?}
* @protected
*/
AMapOverlay.prototype.os;
/**
* @type {?}
* @protected
*/
AMapOverlay.prototype.binder;
}
/**
* @fileoverview added by tsickle
* Generated from: shared/pixel.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class PixelService {
constructor() { }
/**
* @param {?} options
* @return {?}
*/
create(options) {
if (!options) {
return null;
}
if (options instanceof AMap.Pixel) {
return options;
}
if (Array.isArray(options)) {
return new AMap.Pixel(options[0], options[1]);
}
return new AMap.Pixel(options.x || 0, options.y || 0, options.round);
}
}
PixelService.decorators = [
{ type: Injectable, args: [{
providedIn: 'root',
},] }
];
/** @nocollapse */
PixelService.ctorParameters = () => [];
/** @nocollapse */ PixelService.ngInjectableDef = ɵɵdefineInjectable({ factory: function PixelService_Factory() { return new PixelService(); }, token: PixelService, providedIn: "root" });
/**
* @fileoverview added by tsickle
* Generated from: shared/size.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class SizeService {
constructor() { }
/**
* @param {?} options
* @return {?}
*/
create(options) {
if (!options) {
return null;
}
if (options instanceof AMap.Size || Array.isArray(options)) {
return options;
}
if (options.width !== undefined && options.height !== undefined) {
return new AMap.Size(options.width, options.height);
}
if (options.w !== undefined && options.h !== undefined) {
return new AMap.Size(options.w, options.h);
}
return null;
}
}
SizeService.decorators = [
{ type: Injectable, args: [{
providedIn: 'root',
},] }
];
/** @nocollapse */
SizeService.ctorParameters = () => [];
/** @nocollapse */ SizeService.ngInjectableDef = ɵɵdefineInjectable({ factory: function SizeService_Factory() { return new SizeService(); }, token: SizeService, providedIn: "root" });
/**
* @fileoverview added by tsickle
* Generated from: shared/icon.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class IconService {
/**
* @param {?} pixels
* @param {?} sizes
*/
constructor(pixels, sizes) {
this.pixels = pixels;
this.sizes = sizes;
}
/**
* @param {?} options
* @return {?}
*/
create(options) {
if (!options) {
return null;
}
if (typeof options === 'string') {
return options;
}
if (options instanceof AMap.Icon) {
return options;
}
/** @type {?} */
const iconOption = {};
const { size, image, imageOffset, imageSize } = options;
if (size !== undefined) {
iconOption.size = this.sizes.create(size);
}
if (image !== undefined) {
iconOption.image = image;
}
if (imageOffset !== undefined) {
iconOption.imageOffset = this.pixels.create(imageOffset);
}
if (imageSize !== undefined) {
iconOption.imageSize = this.sizes.create(imageSize);
}
return new AMap.Icon(iconOption);
}
}
IconService.decorators = [
{ type: Injectable, args: [{
providedIn: 'root',
},] }
];
/** @nocollapse */
IconService.ctorParameters = () => [
{ type: PixelService },
{ type: SizeService }
];
/** @nocollapse */ IconService.ngInjectableDef = ɵɵdefineInjectable({ factory: function IconService_Factory() { return new IconService(ɵɵinject(PixelService), ɵɵinject(SizeService)); }, token: IconService, providedIn: "root" });
if (false) {
/**
* @type {?}
* @private
*/
IconService.prototype.pixels;
/**
* @type {?}
* @private
*/
IconService.prototype.sizes;
}
/**
* @fileoverview added by tsickle
* Generated from: shared/marker-label.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class MarkerLabelService {
/**
* @param {?} pixel
*/
constructor(pixel) {
this.pixel = pixel;
}
/**
* @param {?} options
* @return {?}
*/
create(options) {
if (options) {
/** @type {?} */
const label = {};
if (options.content !== undefined) {
label.content = options.content;
}
if (options.offset !== undefined) {
if (options.offset instanceof AMap.Pixel) {
label.offset = options.offset;
}
else {
label.offset = this.pixel.create(options.offset);
}
}
if (options.direction !== undefined) {
label.direction = options.direction;
}
return label;
}
return null;
}
}
MarkerLabelService.decorators = [
{ type: Injectable, args: [{
providedIn: 'root',
},] }
];
/** @nocollapse */
MarkerLabelService.ctorParameters = () => [
{ type: PixelService }
];
/** @nocollapse */ MarkerLabelService.ngInjectableDef = ɵɵdefineInjectable({ factory: function MarkerLabelService_Factory() { return new MarkerLabelService(ɵɵinject(PixelService)); }, token: MarkerLabelService, providedIn: "root" });
if (false) {
/**
* @type {?}
* @private
*/
MarkerLabelService.prototype.pixel;
}
/**
* @fileoverview added by tsickle
* Generated from: components/amap-info-window/amap-info-window.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
const TAG$6 = 'AmapInfoWindow';
class AmapInfoWindowService {
/**
* @param {?} amaps
* @param {?} logger
* @param {?} ngZone
*/
constructor(amaps, logger, ngZone) {
this.amaps = amaps;
this.logger = logger;
this.ngZone = ngZone;
this.infoWindow$ = new ReplaySubject(1);
}
/**
* 获取信息窗体
* @return {?}
*/
get() {
return this.infoWindow$.asObservable();
}
/**
* 创建 AMap.InfoWindow
* @param {?} options 选项
* @return {?}
*/
create(options) {
return this.amaps.get().pipe(map((/**
* @param {?} m
* @return {?}
*/
m => {
this.map = m;
this.infoWindow = this.ngZone.runOutsideAngular((/**
* @return {?}
*/
() => new AMap.InfoWindow(options)));
this.logger.d(TAG$6, 'new InfoWindow created.');
this.infoWindow$.next(this.infoWindow);
this.infoWindow$.complete();
return this.infoWindow;
})));
}
/**
* 销毁
* @return {?}
*/
destroy() {
this.get().subscribe((/**
* @param {?} w
* @return {?}
*/
w => {
w.close();
this.logger.d(TAG$6, 'InfoWindow destroyed.');
this.infoWindow = null;
this.map = null;
}));
}
/**
* 打开
* @param {?=} position
* @return {?}
*/
open(position) {
this.get().subscribe((/**
* @param {?} w
* @return {?}
*/
w => w.open(this.map, position)));
}
/**
* 在覆盖物上打开窗体
* @param {?} marker
* @return {?}
*/
openOnMark(marker) {
zip(marker, this.get()).subscribe((/**
* @param {?} __0
* @return {?}
*/
([m, w]) => {
w.open(this.map, m.getPosition());
}));
}
/**
* 关闭
* @return {?}
*/
close() {
this.get().subscribe((/**
* @param {?} w
* @return {?}
*/
w => w.close()));
}
}
AmapInfoWindowService.decorators = [
{ type: Injectable }
];
/** @nocollapse */
AmapInfoWindowService.ctorParameters = () => [
{ type: AMapService },
{ type: LoggerService },
{ type: NgZone }
];
if (false) {
/**
* @type {?}
* @private
*/
AmapInfoWindowService.prototype.map;
/**
* @type {?}
* @private
*/
AmapInfoWindowService.prototype.infoWindow;
/**
* @type {?}
* @private
*/
AmapInfoWindowService.prototype.infoWindow$;
/**
* @type {?}
* @private
*/
AmapInfoWindowService.prototype.amaps;
/**
* @type {?}
* @private
*/
AmapInfoWindowService.prototype.logger;
/**
* @type {?}
* @private
*/
AmapInfoWindowService.prototype.ngZone;
}
/**
* @fileoverview added by tsickle
* Generated from: components/amap-info-window/amap-info-window.component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
const TAG$7 = 'amap-info-window';
/** @type {?} */
const ALL_OPTIONS$1 = [
'isCustom',
'autoMove',
'closeWhenClickMap',
'content',
'size',
'anchor',
'offset',
'position',
'showShadow',
];
class AmapInfoWindowComponent {
/**
* @param {?} os
* @param {?} binder
* @param {?} amaps
* @param {?} el
* @param {?} logger
* @param {?} pixels
* @param {?} sizes
* @param {?} ngZone
*/
constructor(os, binder, amaps, el, logger, pixels, sizes, ngZone) {
this.os = os;
this.binder = binder;
this.amaps = amaps;
this.el = el;
this.logger = logger;
this.pixels = pixels;
this.sizes = sizes;
this.ngZone = ngZone;
/**
* 额外:是否开启
*/
this.isOpen = false;
// ---- Events ----
this.naReady = new EventEmitter();
this.isOpenChange = new EventEmitter();
this.inited = false;
/** @type {?} */
const w = this.os.get();
this.naOpen = this.binder.bindEvent(w, 'open');
this.naClose = this.binder.bindEvent(w, 'close');
this.naChange = this.binder.bindEvent(w, 'change');
}
/**
* @param {?} changes
* @return {?}
*/
ngOnChanges(changes) {
/** @type {?} */
const filter = ChangeFilter.of(changes);
/** @type {?} */
const iw = this.get();
if (!this.inited) {
this.amaps.get().subscribe((/**
* @return {?}
*/
() => {
this.logger.d(TAG$7, 'initializing ...');
// bind isOpenChange events:
this.subscriptions = this.binder.bindEvent(iw, 'open').subscribe((/**
* @return {?}
*/
() => {
if (!this.isOpen) {
this.isOpen = true;
this.isOpenChange.emit(true);
}
}));
this.subscriptions.add(this.binder.bindEvent(iw, 'close').subscribe((/**
* @return {?}
*/
() => {
if (this.isOpen) {
th