location maps
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
<div>
|
||||
<capacitor-google-map #map id="google-map"></capacitor-google-map>
|
||||
</div>
|
||||
@@ -0,0 +1,6 @@
|
||||
capacitor-google-map {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
height: 340px;
|
||||
//border-radius: 10px;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
|
||||
import { TrackingComponent } from './tracking.component';
|
||||
|
||||
describe('TrackingComponent', () => {
|
||||
let component: TrackingComponent;
|
||||
let fixture: ComponentFixture<TrackingComponent>;
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ TrackingComponent ],
|
||||
imports: [IonicModule.forRoot()]
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(TrackingComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,70 @@
|
||||
import { Component, OnInit, ElementRef, OnDestroy, ViewChild } from '@angular/core';
|
||||
import { GoogleMap } from '@capacitor/google-maps';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { Location, Locations } from '../../interfaces/location';
|
||||
import { MarkerEl } from '../../interfaces/marker';
|
||||
@Component({
|
||||
selector: 'app-tracking',
|
||||
templateUrl: './tracking.component.html',
|
||||
styleUrls: ['./tracking.component.scss'],
|
||||
})
|
||||
export class TrackingComponent implements OnInit {
|
||||
|
||||
@ViewChild('map') public mapEl: ElementRef<HTMLElement>;
|
||||
|
||||
public map: GoogleMap;
|
||||
|
||||
public heading: string = null;
|
||||
|
||||
public description: string = null;
|
||||
|
||||
public locationOptions = {
|
||||
header: 'Asia',
|
||||
subHeader: 'Select a country from the list',
|
||||
message: 'There\'s only three :)',
|
||||
translucent: true,
|
||||
};
|
||||
|
||||
private markers: Array<MarkerEl> = [];
|
||||
|
||||
private ids: Array<string> = [];
|
||||
|
||||
constructor() {
|
||||
this.heading = 'Select a country from the above menu';
|
||||
this.description = 'Interact with the markers that are displayed for each selected country';
|
||||
setTimeout(async () => {
|
||||
await this.createMap();
|
||||
}, 500);
|
||||
}
|
||||
|
||||
ionViewDidEnter() {
|
||||
debugger;
|
||||
setTimeout(async () => {
|
||||
await this.createMap();
|
||||
}, 500);
|
||||
}
|
||||
ngOnInit() {}
|
||||
/**
|
||||
* @private
|
||||
* @async
|
||||
* @method createMap
|
||||
* @description Creates a GoogleMap instance which is rendered within the DOM
|
||||
* @returns {Promise<void>}
|
||||
* @memberof HomePage
|
||||
*/
|
||||
private async createMap(): Promise<void> {
|
||||
this.map = await GoogleMap.create({
|
||||
id: 'google-map',
|
||||
element: this.mapEl.nativeElement,
|
||||
apiKey: environment.keys.googleMaps,
|
||||
forceCreate: true,
|
||||
config: {
|
||||
center: {
|
||||
lat: 1.0667172756631198,
|
||||
lng: 103.96214500683499
|
||||
},
|
||||
zoom: 5
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user