| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- "use strict";
- var __decorate = (this && this.__decorate) || function (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;
- };
- var __metadata = (this && this.__metadata) || function (k, v) {
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var core_1 = require("@angular/core");
- var common_1 = require("@angular/common");
- var GMap = /** @class */ (function () {
- function GMap(el, differs, cd, zone) {
- this.el = el;
- this.cd = cd;
- this.zone = zone;
- this.onMapClick = new core_1.EventEmitter();
- this.onOverlayClick = new core_1.EventEmitter();
- this.onOverlayDblClick = new core_1.EventEmitter();
- this.onOverlayDragStart = new core_1.EventEmitter();
- this.onOverlayDrag = new core_1.EventEmitter();
- this.onOverlayDragEnd = new core_1.EventEmitter();
- this.onMapReady = new core_1.EventEmitter();
- this.onMapDragEnd = new core_1.EventEmitter();
- this.onZoomChanged = new core_1.EventEmitter();
- this.differ = differs.find([]).create(null);
- }
- GMap.prototype.ngAfterViewChecked = function () {
- if (!this.map && this.el.nativeElement.offsetParent) {
- this.initialize();
- }
- };
- GMap.prototype.initialize = function () {
- var _this = this;
- this.map = new google.maps.Map(this.el.nativeElement.children[0], this.options);
- this.onMapReady.emit({
- map: this.map
- });
- if (this.overlays) {
- for (var _i = 0, _a = this.overlays; _i < _a.length; _i++) {
- var overlay = _a[_i];
- overlay.setMap(this.map);
- this.bindOverlayEvents(overlay);
- }
- }
- this.map.addListener('click', function (event) {
- _this.zone.run(function () {
- _this.onMapClick.emit(event);
- });
- });
- this.map.addListener('dragend', function (event) {
- _this.zone.run(function () {
- _this.onMapDragEnd.emit(event);
- });
- });
- this.map.addListener('zoom_changed', function (event) {
- _this.zone.run(function () {
- _this.onZoomChanged.emit(event);
- });
- });
- };
- GMap.prototype.bindOverlayEvents = function (overlay) {
- var _this = this;
- overlay.addListener('click', function (event) {
- _this.zone.run(function () {
- _this.onOverlayClick.emit({
- originalEvent: event,
- 'overlay': overlay,
- map: _this.map
- });
- });
- });
- overlay.addListener('dblclick', function (event) {
- _this.zone.run(function () {
- _this.onOverlayDblClick.emit({
- originalEvent: event,
- 'overlay': overlay,
- map: _this.map
- });
- });
- });
- if (overlay.getDraggable()) {
- this.bindDragEvents(overlay);
- }
- };
- GMap.prototype.ngDoCheck = function () {
- var _this = this;
- var changes = this.differ.diff(this.overlays);
- if (changes && this.map) {
- changes.forEachRemovedItem(function (record) {
- google.maps.event.clearInstanceListeners(record.item);
- record.item.setMap(null);
- });
- changes.forEachAddedItem(function (record) {
- record.item.setMap(_this.map);
- record.item.addListener('click', function (event) {
- _this.zone.run(function () {
- _this.onOverlayClick.emit({
- originalEvent: event,
- overlay: record.item,
- map: _this.map
- });
- });
- });
- if (record.item.getDraggable()) {
- _this.bindDragEvents(record.item);
- }
- });
- }
- };
- GMap.prototype.bindDragEvents = function (overlay) {
- var _this = this;
- overlay.addListener('dragstart', function (event) {
- _this.zone.run(function () {
- _this.onOverlayDragStart.emit({
- originalEvent: event,
- overlay: overlay,
- map: _this.map
- });
- });
- });
- overlay.addListener('drag', function (event) {
- _this.zone.run(function () {
- _this.onOverlayDrag.emit({
- originalEvent: event,
- overlay: overlay,
- map: _this.map
- });
- });
- });
- overlay.addListener('dragend', function (event) {
- _this.zone.run(function () {
- _this.onOverlayDragEnd.emit({
- originalEvent: event,
- overlay: overlay,
- map: _this.map
- });
- });
- });
- };
- GMap.prototype.getMap = function () {
- return this.map;
- };
- __decorate([
- core_1.Input(),
- __metadata("design:type", Object)
- ], GMap.prototype, "style", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], GMap.prototype, "styleClass", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Object)
- ], GMap.prototype, "options", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Array)
- ], GMap.prototype, "overlays", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], GMap.prototype, "onMapClick", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], GMap.prototype, "onOverlayClick", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], GMap.prototype, "onOverlayDblClick", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], GMap.prototype, "onOverlayDragStart", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], GMap.prototype, "onOverlayDrag", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], GMap.prototype, "onOverlayDragEnd", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], GMap.prototype, "onMapReady", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], GMap.prototype, "onMapDragEnd", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], GMap.prototype, "onZoomChanged", void 0);
- GMap = __decorate([
- core_1.Component({
- selector: 'p-gmap',
- template: "<div [ngStyle]=\"style\" [class]=\"styleClass\"></div>"
- }),
- __metadata("design:paramtypes", [core_1.ElementRef, core_1.IterableDiffers, core_1.ChangeDetectorRef, core_1.NgZone])
- ], GMap);
- return GMap;
- }());
- exports.GMap = GMap;
- var GMapModule = /** @class */ (function () {
- function GMapModule() {
- }
- GMapModule = __decorate([
- core_1.NgModule({
- imports: [common_1.CommonModule],
- exports: [GMap],
- declarations: [GMap]
- })
- ], GMapModule);
- return GMapModule;
- }());
- exports.GMapModule = GMapModule;
- //# sourceMappingURL=gmap.js.map
|