Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { HIDE_TRAJECTORY_KEY, ENABLE_SWAP_DIRECTION } from '../../const';
import { GoogleMap, GoogleMapsEvent, GoogleMapsLatLng } from 'ionic-native';
import { Platform } from 'ionic-angular';
import { Component, OnChanges, OnDestroy } from '@angular/core';
import { Bus } from '../../models/bus';
import { Line, Itinerary } from '../../models/itinerary';
import { MarkerController } from './marker';
import { PreferencesManager } from '../../managers/preferences';
// Configuration for the map available resources and presentation
const mapConfig: any = {
mapType: 'MAP_TYPE_NORMAL',
controls: { compass: true, myLocationButton: true, indoorPicker: false, zoom: false },
camera: { latLng: new GoogleMapsLatLng(-22.9083, -43.1964), zoom: 12 },
};
/**
* Represents the HTML component.
* @class {GoogleMapsComponent}
*/
@Component({
selector: 'google-maps',
templateUrl: 'template.html',
inputs: ['markers', 'line', 'trajectory'],
})
export class GoogleMapsComponent implements OnChanges, OnDestroy {
private map: GoogleMap;
private markers: Bus[];
private trajectory: Itinerary;
this._zone.run(() => {
let myPosition = new GoogleMapsLatLng(38.9072, -77.0369);
console.log("My position is", myPosition);
this.map.animateCamera({ target: myPosition, zoom: 10 });
});
private getMarkerData(bus: Bus): GoogleMapsMarkerOptions {
return {
position: new GoogleMapsLatLng(bus.Latitude, bus.Longitude),
icon: { url: this.getIconPath(bus.Timestamp), size: { width: BusIcon.WIDTH, height: BusIcon.HEIGHT } },
title: this.formatInfoWindow(bus),
};
}
private getMarkerSpotData(spot: Spot, returning: boolean, color: string): GoogleMapsMarkerOptions {
let obj: any = { position: new GoogleMapsLatLng(spot.Latitude, spot.Longitude) };
obj.title = (!returning) ? 'PONTO INICIAL' : 'PONTO FINAL';
obj.icon = color;
return obj;
}
const bounds = filtered.map((coord: Coordinates) => {
return new GoogleMapsLatLng(coord.latitude, coord.longitude);
});
private updatePosition(bus: Bus): void {
this.markers[bus.Order].setPosition(new GoogleMapsLatLng(bus.Latitude, bus.Longitude));
}