Add driving animation for google maps
This commit is contained in:
parent
92cfc07166
commit
70d7189f4a
21993
components/control_center/package-lock.json
generated
21993
components/control_center/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -12,6 +12,7 @@
|
|||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@agm/core": "^3.0.0-beta.0",
|
||||||
"@angular-devkit/schematics": "~9.1.7",
|
"@angular-devkit/schematics": "~9.1.7",
|
||||||
"@angular/animations": "~9.1.9",
|
"@angular/animations": "~9.1.9",
|
||||||
"@angular/cdk": "9.2.4",
|
"@angular/cdk": "9.2.4",
|
||||||
@ -19,7 +20,6 @@
|
|||||||
"@angular/compiler": "~9.1.9",
|
"@angular/compiler": "~9.1.9",
|
||||||
"@angular/core": "~9.1.9",
|
"@angular/core": "~9.1.9",
|
||||||
"@angular/forms": "~9.1.9",
|
"@angular/forms": "~9.1.9",
|
||||||
"@angular/google-maps": "^12.0.2",
|
|
||||||
"@angular/localize": "~9.1.9",
|
"@angular/localize": "~9.1.9",
|
||||||
"@angular/material": "9.2.4",
|
"@angular/material": "9.2.4",
|
||||||
"@angular/platform-browser": "~9.1.9",
|
"@angular/platform-browser": "~9.1.9",
|
||||||
@ -40,6 +40,7 @@
|
|||||||
"@angular/compiler-cli": "~9.1.9",
|
"@angular/compiler-cli": "~9.1.9",
|
||||||
"@angular/language-service": "~9.1.9",
|
"@angular/language-service": "~9.1.9",
|
||||||
"@compodoc/compodoc": "~1.1.11",
|
"@compodoc/compodoc": "~1.1.11",
|
||||||
|
"@types/googlemaps": "^3.39.13",
|
||||||
"@types/jasmine": "~3.4.6",
|
"@types/jasmine": "~3.4.6",
|
||||||
"@types/jasminewd2": "~2.0.8",
|
"@types/jasminewd2": "~2.0.8",
|
||||||
"@types/node": "^12.12.42",
|
"@types/node": "^12.12.42",
|
||||||
|
|||||||
@ -15,13 +15,11 @@ import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
|||||||
import {MatButtonModule} from '@angular/material/button';
|
import {MatButtonModule} from '@angular/material/button';
|
||||||
import {MatInputModule} from '@angular/material/input';
|
import {MatInputModule} from '@angular/material/input';
|
||||||
import {MatSlideToggleModule} from '@angular/material/slide-toggle';
|
import {MatSlideToggleModule} from '@angular/material/slide-toggle';
|
||||||
import {MatSliderModule} from "@angular/material/slider";
|
import {AgmCoreModule, GoogleMapsAPIWrapper} from '@agm/core';
|
||||||
import { GoogleMapsModule } from '@angular/google-maps';
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [LandingComponent],
|
declarations: [LandingComponent],
|
||||||
imports: [
|
imports: [
|
||||||
GoogleMapsModule,
|
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
BrowserAnimationsModule,
|
BrowserAnimationsModule,
|
||||||
@ -33,10 +31,13 @@ import { GoogleMapsModule } from '@angular/google-maps';
|
|||||||
MatButtonModule,
|
MatButtonModule,
|
||||||
MatInputModule,
|
MatInputModule,
|
||||||
MatSlideToggleModule,
|
MatSlideToggleModule,
|
||||||
MatSliderModule
|
AgmCoreModule.forRoot({
|
||||||
|
apiKey: 'AIzaSyCXF-INAlIkG9uPBofGLUCyHthaLxN-3PY',
|
||||||
|
})
|
||||||
],
|
],
|
||||||
// enables injecting
|
// enables injecting
|
||||||
providers: [
|
providers: [
|
||||||
|
GoogleMapsAPIWrapper,
|
||||||
RestService,
|
RestService,
|
||||||
WebsocketService,
|
WebsocketService,
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<google-map width="auto" height="100vh"
|
<button (click)="toggleMarker()">Drive!</button>
|
||||||
[zoom]="zoom"
|
|
||||||
[center]="center"
|
<agm-map id="map" #map [zoom]="zoom" [latitude]="center.lat" [longitude]="center.lng" style="height: 900px; width: 1200px">
|
||||||
[options]="options"
|
<agm-marker *ngFor="let m of markers" [iconUrl]="m.iconUrl" [visible]="m.visible" [latitude]="m.lat" [longitude]="m.lng" >
|
||||||
>
|
</agm-marker>
|
||||||
</google-map>
|
</agm-map>
|
||||||
|
|||||||
@ -1,8 +1,5 @@
|
|||||||
import {Component, OnInit, ViewChild} from '@angular/core';
|
import {Component, OnInit, ViewChild} from '@angular/core';
|
||||||
import {RestService} from '../../services/rest.service';
|
import {AgmMap, AgmMarker} from '@agm/core';
|
||||||
import {NGXLogger} from 'ngx-logger';
|
|
||||||
import {Subscription} from 'rxjs';
|
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-landing',
|
selector: 'app-landing',
|
||||||
@ -11,80 +8,59 @@ import {Subscription} from 'rxjs';
|
|||||||
})
|
})
|
||||||
export class LandingComponent implements OnInit {
|
export class LandingComponent implements OnInit {
|
||||||
|
|
||||||
zoom = 12;
|
constructor() {
|
||||||
center: { lat: -33, lng: 151 };
|
|
||||||
options: google.maps.MapOptions = {
|
|
||||||
zoomControl: false,
|
|
||||||
scrollwheel: false,
|
|
||||||
maxZoom: 12,
|
|
||||||
minZoom: 12,
|
|
||||||
disableDefaultUI: true
|
|
||||||
};
|
|
||||||
|
|
||||||
private wsSubscription: Subscription;
|
|
||||||
private wsMessageCounter: number;
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private logger: NGXLogger,
|
|
||||||
private restService: RestService
|
|
||||||
) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
@ViewChild('map') map: AgmMap;
|
||||||
// perform test rest call as observable
|
|
||||||
this.observableCall();
|
|
||||||
|
|
||||||
// perform test rest call as promise (shorter - will only be executed exactly once)
|
|
||||||
this.promiseCall();
|
|
||||||
|
|
||||||
// perform test ws send / receive
|
zoom = 14;
|
||||||
/* setTimeout(() => {
|
center = {lat: 53.531248, lng: 13.409038};
|
||||||
this.wsCall();
|
|
||||||
},
|
// Test Data
|
||||||
1000);*/
|
markers = [
|
||||||
|
{
|
||||||
|
Id: 1,
|
||||||
|
name: 'Car-1',
|
||||||
|
lat: 53.521248,
|
||||||
|
lng: 13.399038,
|
||||||
|
visible: true,
|
||||||
|
iconUrl: 'assets/pictures/car.png'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Id: 2,
|
||||||
|
name: 'Car-2',
|
||||||
|
lat: 53.531248,
|
||||||
|
lng: 13.409038,
|
||||||
|
visible: true,
|
||||||
|
iconUrl: 'assets/pictures/car.png'
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private observableCall(): void {
|
getDelta(source, destination, steps) {
|
||||||
|
return {
|
||||||
const subscription = this.restService.testCall(1).subscribe(
|
lat: (destination.lat - source.lat) / steps,
|
||||||
// subscribe with lambda function
|
lng: (destination.lng - source.lng) / steps
|
||||||
response => {
|
};
|
||||||
this.logger.debug('Execute obs test call', response);
|
|
||||||
subscription.unsubscribe();
|
|
||||||
},
|
|
||||||
error => {
|
|
||||||
this.logger.error('Error while executing obs test call', error);
|
|
||||||
subscription.unsubscribe();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private promiseCall(): void {
|
toggleMarker() {
|
||||||
this.restService.testCall(2).toPromise()
|
const delta = this.getDelta(this.markers[0], this.markers[1], 100);
|
||||||
// lambda for success
|
|
||||||
.then(response => {
|
this.move(this.markers[0], delta, 0, 10, 100);
|
||||||
this.logger.debug('Execute obs test call', response);
|
|
||||||
})
|
|
||||||
// lambda for fail
|
|
||||||
.catch(error => {
|
|
||||||
this.logger.error('Error while executing obs test call', error);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* private wsCall(): void {
|
move(source, delta, counter, delay, steps) {
|
||||||
this.wsMessageCounter = 0;
|
source.lat += delta.lat;
|
||||||
this.wsSubscription = this.wsService.wsTestCall('Test message').message.subscribe(
|
source.lng += delta.lng;
|
||||||
result => {
|
if (counter !== steps) {
|
||||||
this.logger.debug('ws call result', result);
|
counter++;
|
||||||
if (this.wsMessageCounter >= 2) {
|
setTimeout(this.move.bind(this), delay, source, delta, counter, delay, steps);
|
||||||
this.wsSubscription.unsubscribe();
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
error => {
|
|
||||||
this.logger.error('ws call error', error);
|
|
||||||
this.wsSubscription.unsubscribe();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
components/control_center/src/assets/pictures/car.png
Normal file
BIN
components/control_center/src/assets/pictures/car.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 316 B |
Loading…
x
Reference in New Issue
Block a user