|
|
@@ -1,5 +1,11 @@
|
|
|
import { Component, OnInit, ViewRef } from '@angular/core';
|
|
|
-import { BcInfoService } from './bc-info.service';
|
|
|
+
|
|
|
+import ExtentIteraction from 'ol/interaction/Extent'
|
|
|
+import { shiftKeyOnly } from 'ol/events/condition';
|
|
|
+import {
|
|
|
+ Extent,
|
|
|
+ getArea
|
|
|
+ } from 'ol/extent'
|
|
|
|
|
|
import {
|
|
|
HsMapService,
|
|
|
@@ -7,28 +13,53 @@ import {
|
|
|
HsLayoutService
|
|
|
} from 'hslayers-ng';
|
|
|
|
|
|
+import { BcInfoService } from './bc-info.service';
|
|
|
+
|
|
|
@Component({
|
|
|
selector: 'blockchain-info',
|
|
|
templateUrl: 'bc-info.component.html',
|
|
|
})
|
|
|
+export class BcInfoComponent implements HsPanelComponent {
|
|
|
+ private extentIteraction: ExtentIteraction;
|
|
|
+
|
|
|
+ choosingArea: boolean = false;
|
|
|
+
|
|
|
+ user: string = 'kunickyd@test';
|
|
|
+ assetId: string = "coin#test"
|
|
|
+ userPrivateKey: string = '5ee90333f04f42f457f2d10f1cbd7ec870b041184074dce2b744aa17e67b1e9a';
|
|
|
+ userBalance: number;
|
|
|
+ extent: Extent;
|
|
|
+ price: number;
|
|
|
|
|
|
-export class BcInfoComponent implements OnInit, HsPanelComponent {
|
|
|
viewRef: ViewRef;
|
|
|
data: any;
|
|
|
- name: string;
|
|
|
-
|
|
|
+ name: string = "bc-panel";
|
|
|
+
|
|
|
constructor(
|
|
|
private bcInfoService: BcInfoService,
|
|
|
private mapService: HsMapService,
|
|
|
private hsLayoutService: HsLayoutService
|
|
|
- ) {
|
|
|
- this.name = "bc-panel";
|
|
|
+ ) {
|
|
|
+ this.extentIteraction = new ExtentIteraction({ condition: shiftKeyOnly });
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
isVisible(): boolean {
|
|
|
return this.hsLayoutService.panelVisible(this.name);
|
|
|
}
|
|
|
|
|
|
- ngOnInit() { }
|
|
|
+ onChooseArea(): void {
|
|
|
+ let map = this.mapService.getMap();
|
|
|
+
|
|
|
+ this.choosingArea = true;
|
|
|
+
|
|
|
+ map.getTargetElement().addEventListener("mouseup", async (event) => {
|
|
|
+ if(this.extent){
|
|
|
+ this.price = await this.bcInfoService.getPrice(getArea(this.extent));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ this.extentIteraction.on("extentchanged", (event) => this.extent = event.extent);
|
|
|
+
|
|
|
+ map.addInteraction(this.extentIteraction);
|
|
|
+ }
|
|
|
}
|