Googlemap.getCameraPosition() doesn't do any thing for iOS , neither it goes to then block or catch bolck and doesn't console anything inside it.
But on android it is working perfectly fine.
Also other methods of GoogleMap is not working for iOS, the pointer never goes to this.map.on(GoogleMapsEvent.MAP_READY) in case of iOS
import { Component, ViewChild, ElementRef, OnInit, AfterViewInit } from '#angular/core';
import { NavController,NavParams,Events, ViewController, Platform } from 'ionic-angular';
import { GoogleMap, GoogleMapsEvent, GoogleMapsLatLng,CameraPosition, Geolocation } from 'ionic-native';
import _ from 'lodash';
#Component({
selector: 'page-map-modal',
templateUrl: 'map-modal.html'
})
export class MapModalPage implements OnInit,AfterViewInit {
#ViewChild('map') mapElement: ElementRef;
lat: any;
lng: any;
map:GoogleMap;
target:any;
position:any;
constructor(public navCtrl: NavController,
public viewCtrl: ViewController,
public platform: Platform,
public events: Events,
private alert:AlertController,
private navParam: NavParams) {
this.target = this.navParam.get('location');
}
//get current location of user
ngOnInit() {
Geolocation.getCurrentPosition().then((result)=>{
this.position = result;
},(error)=>{
// console.log(error,"error occured while getting geolocation");
})
}
ngAfterViewInit(){
this.platform.ready().then(() => {
this.loadMap();
});
}
loadMap(){
let location = null;
if(this.target['lat'] && this.target['lng']){
location = new GoogleMapsLatLng(Number(this.target['lat']),Number(this.target['lng']));
}else{
location = new GoogleMapsLatLng(24.795464,46.699796);
}
this.map = new GoogleMap('map', {
'backgroundColor': 'white',
'controls': {
'compass': true,
'myLocationButton': true,
'indoorPicker': true,
'zoom': true
},
'gestures': {
'scroll': true,
'tilt': false,
'rotate': true,
'zoom': true
},
'camera': {
'latLng': location,
'tilt': 20,
'zoom': 15,
'bearing': 50
}
});
this.map.setCenter(location);
this.map.on(GoogleMapsEvent.MAP_READY).subscribe(() => {
this.map.refreshLayout();
this.map.clear();
if((_.isEmpty(this.target['lat']) || this.target['lat'] == '0') && (_.isEmpty(this.target['lng']) || this.target['lng'] == '0')){
this.map.getMyLocation().then((target)=>{
location = new GoogleMapsLatLng(target.latLng.lat,target.latLng.lng);
let position: CameraPosition = {
target: location,
zoom: 15,
tilt: 30,
bearing: 50
};
// // move the map's camera to position
this.map.moveCamera(position);
this.map.setCenter(location);
// console.log(target.latLng.lat, target.latLng.lng,"current user location");
},(error)=>{
// console.log(error,"error in getting current location");
})
}
});
}
dismiss(){
this.navCtrl.pop();
}
pickLocationAndDismiss(){
let target;
this.map.getCameraPosition().then((data)=>{
target = data.target;
this.events.publish('latlng:map',target);
}).catch(err=>{
console.log(err)
});
this.navCtrl.pop();
}
}
Related
I can't call any function by map object.
The map works correctly but I need to add marker or call any function, I couldn't do that.
Is my problem with code or with plugins?
// create location object
const location = new google.maps.LatLng('24.713552', '46.675296');
// create options object
const options = {
center:location,
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP,
draggable: true
};
// create location object
const map = new google.maps.Map(this.mapRef.nativeElement, options);
map.off();// this for e.g.
map.addMarker(markerOptions ).then(marker => {
//alert(marker);
});// or this
Please check plugins in package.json
"#angular/animations": "^5.2.11",
"#angular/common": "^5.2.11",
"#angular/compiler": "^5.2.11",
"#angular/compiler-cli": "^5.2.11",
"#angular/core": "^5.2.11",
"#angular/forms": "^5.2.11",
"#angular/http": "^5.2.11",
"#angular/platform-browser": "^5.2.11",
"#angular/platform-browser-dynamic": "^5.2.11",
"#angular/router": "^5.2.11",
"#ionic-native/core": "^4.9.1",
"#ionic-native/geolocation": "^4.11.0",
"#ionic-native/splash-screen": "4.7.0",
"#ionic-native/status-bar": "4.7.0",
"#ionic/pro": "1.0.20",
"#ionic/storage": "2.1.3",
"#ngx-translate/core": "^8.0.0",
"#ngx-translate/http-loader": "^2.0.1",
"com-sarriaroman-photoviewer": "~1.1.18",
"cordova": "^8.0.0",
"cordova-android": "^7.0.0",
"cordova-common": "^2.2.5",
"cordova-plugin-device": "~2.0.2",
"cordova-plugin-device-motion": "^2.0.1",
"cordova-plugin-geolocation": "^4.0.1",
"cordova-plugin-googlemaps-sdk": "git+https://github.com/mapsplugin/cordova-plugin-googlemaps-sdk.git#2.7.0",
"cordova-plugin-ionic-keyboard": "^2.0.5",
"cordova-plugin-ionic-webview": "^1.2.1",
"cordova-plugin-shake": "^0.6.0",
"cordova-plugin-splashscreen": "~5.0.2",
"cordova-plugin-whitelist": "~1.3.3",
"cordova-plugin-x-socialsharing": "~5.4.1",
"cordova-sqlite-storage": "^2.3.3",
"ionic-angular": "3.9.2",
"ionicons": "3.0.0",
"minimist": "^1.2.0",
"moment": "^2.22.2",
"ng-lazyload-image": "^3.4.2",
"platform": "1.3.5",
"rxjs": "^5.5.11",
"sw-toolbox": "3.6.0",
"uuid": "^3.2.1",
"xml2js": "^0.4.19",
"zone.js": "0.8.26"
"cordova-sqlite-storage": {},
"cordova-plugin-whitelist": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {},
"cordova-plugin-ionic-keyboard": {},
"com-sarriaroman-photoviewer": {},
"cordova-plugin-x-socialsharing": {},
"cordova-plugin-device-motion": {},
"cordova-plugin-shake": {},
"cordova-plugin-googlemaps": {
"API_KEY_FOR_ANDROID": "AIzaSyC4d2sLV_TD274bRUqNqBtGtDVUZFURM3k",
"API_KEY_FOR_IOS": "AIzaSyC4d2sLV_TD274bRUqNqBtGtDVUZFURM3k",
"PLAY_SERVICES_VERSION": "11.8.0",
"ANDROID_SUPPORT_V4_VERSION": "24.1.0"
},
"cordova-plugin-geolocation": {}
The keys only for developing not for production, I test app with browser.
Seems like during you page component load lifecycle method (ionViewDidLoad) you call DisplayMap method which has 'this' reference inside that starts to point to its own scope as opposed to your component's scope. Try changing that method with fat arrow function assignment. This way DisplayMap method won't create its own 'this' pointer:
See below:
import { NavController, Platform, AlertController, ToastController } from 'ionic-angular';
import { TranslateService } from '#ngx-translate/core';
import { Storage } from '#ionic/storage';
import { AddressService } from '../../Providers/address.service';
import { ApiDomain } from '../../Providers/constant';
import { CartPage } from '../cart/cart';
import { Component, ViewChild, ElementRef } from '#angular/core';
declare var google: any;
#Component({
selector: 'page-chooselocation',
templateUrl: 'chooselocation.html'
})
export class ChooseLocationPage {
rootUrl: String = "";
animationsOptions = {
animation: 'ios-transition',
duration: 1000
}
#ViewChild('map') mapRef : ElementRef;
// constructor
constructor( public platform: Platform,
public storage: Storage,
public alertCtrl: AlertController,
public toastCtrl: ToastController,
public navCtrl: NavController,
public translate: TranslateService,
public service: AddressService) {
// read root URL
this.rootUrl = ApiDomain.rootUrl;
}
// ion view did load
ionViewDidLoad()
{
// display map
this.DisplayMap();
}
// display map
DisplayMap = () => {
// read current location
// create location object
const location = new google.maps.LatLng('24.713552', '46.675296');
// create options object
const options = {
center:location,
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP,
draggable: true
};
// create location object
const map = new google.maps.Map(this.mapRef.nativeElement, options);
const markerOptions = {
position: location,
animation: google.maps.Animation.BOUNCE
};
map.addMarker(markerOptions ).then(marker => {
alert(marker);
});
}
}
Alternatively you can try passing your native element reference to DisplayMap method as an argument, but I am unsure if this.mapRef.nativeElement reference is "ready" during ionViewDidLoad method, so its better to check if its valid.
import { NavController, Platform, AlertController, ToastController } from 'ionic-angular';
import { TranslateService } from '#ngx-translate/core';
import { Storage } from '#ionic/storage';
import { AddressService } from '../../Providers/address.service';
import { ApiDomain } from '../../Providers/constant';
import { CartPage } from '../cart/cart';
import { Component, ViewChild, ElementRef } from '#angular/core';
declare var google: any;
#Component({
selector: 'page-chooselocation',
templateUrl: 'chooselocation.html'
})
export class ChooseLocationPage {
rootUrl: String = "";
animationsOptions = {
animation: 'ios-transition',
duration: 1000
}
#ViewChild('map') mapRef : ElementRef;
// constructor
constructor( public platform: Platform,
public storage: Storage,
public alertCtrl: AlertController,
public toastCtrl: ToastController,
public navCtrl: NavController,
public translate: TranslateService,
public service: AddressService) {
// read root URL
this.rootUrl = ApiDomain.rootUrl;
}
// ion view did load
ionViewDidLoad()
{
// display map
this.DisplayMap(this.mapRef.nativeElement);
}
// display map
DisplayMap(mapRef) {
// read current location
// create location object
const location = new google.maps.LatLng('24.713552', '46.675296');
// create options object
const options = {
center:location,
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP,
draggable: true
};
// create location object
const map = new google.maps.Map(mapRef, options);
const markerOptions = {
position: location,
animation: google.maps.Animation.BOUNCE
};
map.addMarker(markerOptions ).then(marker => {
alert(marker);
});
}
}
I found the solution. To create Google Map there are two ways:
1- JavaScript side, like:
// create location object
const location = new google.maps.LatLng('24.713552', '46.675296');
// create options object
const options = {
center:location,
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP,
draggable: true
};
// create location object
const map = new google.maps.Map(this.mapRef.nativeElement, options);
2- native side, like:
this.map = GoogleMaps.create('address-map', mapOptions);
My main problem when I try to mix between them, so I could not call addmarker with JavaScript side.
Full solution is:
// create location object
const location = new google.maps.LatLng('24.713552', '46.675296');
// create options object
const options = {
center:location,
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP,
draggable: true
};
// create location object
const map = new google.maps.Map(mapRef, options);
// call add marker
this.marker = this.AddMarker(location, map);
// call add listener
google.maps.event.addListener(this.marker, 'dragend', () => {
// toggle bounce
this.toggleBounce(this.marker);
});
// call add listener
google.maps.event.addListener(this.marker, 'click', () => {
// alert(this.marker);
});
Im getting cordova notification on the console when I try to see my current country name on the browser.
There's something method or alternative to show me that on my tests.html, like in an input field (in the browser)?
On the other hand, if exist another alternative to show actual country name, please tell me.
tests.ts
import { Component, ViewChild, ElementRef } from "#angular/core";
import { NavController, IonicPage, NavParams } from "ionic-angular";
import {
NativeGeocoder,
NativeGeocoderReverseResult
} from "#ionic-native/native-geocoder";
import { Geolocation } from "#ionic-native/geolocation";
declare var google;
#IonicPage()
#Component({
selector: "page-tests",
templateUrl: "tests.html"
})
export class TestsPage {
#ViewChild("mapSmall") mapElement: ElementRef;
map: any;
message: any;
location: any;
gmLocation: { lat: number; lng: number } = { lat: 0, lng: 0 };
constructor(
public navCtrl: NavController,
private geolocation: Geolocation,
private nativeGeocoder: NativeGeocoder,
public navParams: NavParams,
) {
this.onLocateUser();
}
onLocateUser() {
this.geolocation
.getCurrentPosition()
.then(location => {
console.log(
"position gotten: long:",
location.coords.longitude,
" lat:",
location.coords.latitude
);
this.location = location;
this.gmLocation.lat = location.coords.latitude;
this.gmLocation.lng = location.coords.longitude;
this.nativeGeocoder.reverseGeocode(location.coords.latitude,location.coords.longitude)
.then((result: NativeGeocoderReverseResult) => console.log(JSON.stringify(result.countryName)))
.catch((error: any) => console.log(error));
})
.catch(error => {
console.log("Error getting location", error);
});
}
ionViewDidLoad() {
let latlng = new google.maps.LatLng(
this.gmLocation.lat,
this.gmLocation.lat
);
setTimeout(() => {
this.loadMap(latlng);
this.addMarker(this.gmLocation.lat, this.gmLocation.lng);
}, 100);
}
...
}
Need help with Google Directions Service with ionic2. I am trying to set the distance and duration variables after calculating it via the route function. The value is coming as undefined when i access in another method (like the onClickMap here).
Below is the code that I have created:
import { Component } from '#angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { Geolocation } from '#ionic-native/geolocation';
declare var google;
#IonicPage()
#Component({
selector: 'page-activity-detail',
templateUrl: 'activity-detail.html',
})
export class ActivityDetailPage {
public dist: any;
public dur: any;
latLng: any;
directionsDisplay = new google.maps.DirectionsRenderer;
constructor(public navCtrl: NavController, public navParams: NavParams, public geolocation: Geolocation) {
}
ionViewDidLoad() {
this.geolocation.getCurrentPosition().then((position) => {
this.latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
let destination = new google.maps.LatLng(this.activity.address.latitude, this.activity.address.longitude);
let directionService = new google.maps.DirectionsService;
directionService.route({
origin: this.latLng,
destination: destination,
travelMode: 'DRIVING',
unitSystem: google.maps.UnitSystem.IMPERIAL,
provideRouteAlternatives: false
}, function(response, status) {
if (status == 'OK') {
let t = 0;
let d = 0;
let myroute = response.routes[0];
console.log(myroute);
for (let i = 0; i < myroute.legs.length; i++) {
t += myroute.legs[i].distance.value;
d += myroute.legs[i].duration.value;
}
this.dist = t / 1000;
this.dur = d /60;
} else {
console.log(status);
}
});
}, (err) => {
console.log(err);
});
}
onClickMap(){
alert(this.dist);
alert(this.dur);
}
}
I have one screen, which have two gridview . each grid view will populate some value after api calling. so my page will have 2 api calling. so when i call my api call method under constructor or ionViewDidEnter its not working. it allowing only one method to exeute.
here is my two api call method on one page .ts
Even i put under my constructor. But its not showing the data. so if i want to call the both api and need to display the data means how can i do that.please help me out. i was not able to find it out !!
Thanks in advance
updated:
import { Component, ViewChild } from '#angular/core';
import { AlertController, App, FabContainer, ItemSliding, List, ModalController, NavController, ToastController, LoadingController, Refresher } from 'ionic-angular';
import { CategoryDetailPage } from '../categorydetail/categorydetail';
import { ConferenceData } from '../../providers/conference-data';
import { UserData } from '../../providers/user-data';
import { SessionDetailPage } from '../session-detail/session-detail';
import { ScheduleFilterPage } from '../schedule-filter/schedule-filter';
import {Http, Headers } from '#angular/http';
import 'rxjs/add/operator/map';
import { AuthService } from '../../providers/AuthService';
#Component({
selector: 'page-speaker-list',
templateUrl: 'speaker-list.html'
})
export class SpeakerListPage {
loading: any;
data: any;
Catdata: any;
Catdatanames: any;
resdata: any;
resCatdata: any;
resCatdatanames: any;
loginData: {username?: string} = {};
resloginData: {username?: string} = {};
constructor(
public alertCtrl: AlertController,
public app: App,
public loadingCtrl: LoadingController,
public modalCtrl: ModalController,
public navCtrl: NavController,
public toastCtrl: ToastController,
public confData: ConferenceData,
public user: UserData,
public http:Http,
public authService: AuthService
) {
}
ionViewDidEnter() {
this.show();
this.another();
}
show() {
this.showLoader();
this.authService.subs(this.loginData).then((result) => {
this.loading.dismiss();
this.data = result;
if(this.data.status == 1)
{
this.Catdata = this.data.SubjectList;
//this.Catdata.forEach(category => console.log(category.CatID));
for(let i=0; i<this.Catdata.length; i++) {
// console.log(this.Catdata[i].SubjectName);
}
}
else if(this.data.status == 0) {
let alert = this.alertCtrl.create({
title: 'Error',
subTitle: 'Please Enter Valid Username & Password',
buttons: ['OK']
});
alert.present();
}
}, (err) => {
this.loading.dismiss();
});
}
another() {
this.authService.allresources(this.resloginData).then((result) => {
this.resdata = result;
if(this.resdata.status == 1)
{
this.resCatdata = this.resdata.SubjectList;
for(let i=0; i<this.resCatdata.length; i++) {
// console.log(this.resCatdata[i].FileName);
}
}
else if(this.resdata.status == 0) {
let alert = this.alertCtrl.create({
title: 'Error',
subTitle: 'Please Enter Valid Username & Password',
buttons: ['OK']
});
alert.present();
}
}, (err) => {
});
}
showLoader(){
this.loading = this.loadingCtrl.create({
content: 'Authenticating...'
});
this.loading.present();
}
}
I am new to angular2 and trying to find the coordinates(latitude,longitude) using the location.
here is my code,
GeoService.ts
import { Injectable } from '#angular/core';
import { Http } from '#angular/http';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';
#Injectable()
export class GeoService {
constructor(private http: Http) { }
getLocation(term: string) {
return this.http.get('http://maps.google.com/maps/api/geocode/json?address=' + term + 'CA&sensor=false').map
((response) => response.json());
}
// tslint:disable-next-line:eofline
}
app.component.html
<!DOCTYPE HTML>
<h1> {{title}} </h1>
<input type="text" [(ngModel)]="location" />
<button (click)="findLocation($event)">Find location</button>
<sebm-google-map
[latitude]="lat"
[longitude]="lng"
[zoom]="zoom"
[disableDefaultUI]="false"
[zoomControl]="false"
(mapClick)="mapClicked($event)">
<sebm-google-map-marker
*ngFor="let m of markers; let i = index"
(markerClick)="clickedMarker(m.label, i)"
[latitude]="m.lat"
[longitude]="m.lng"
[label]="m.label"
[markerDraggable]="m.draggable"
(dragEnd)="markerDragEnd(m, $event)">
<sebm-google-map-info-window>
<strong>InfoWindow content</strong>
</sebm-google-map-info-window>
</sebm-google-map-marker>
<sebm-google-map-circle [latitude]="lat + 0.3" [longitude]="lng"
[radius]="5000"
[fillColor]="'red'"
[circleDraggable]="true"
[editable]="true">
</sebm-google-map-circle>
</sebm-google-map>
app.component.ts
import { Component } from '#angular/core';
import { GeoService } from './GeoService';
#Component({
selector: 'my-app',
moduleId: module.id,
templateUrl: `./app.component.html`,
styleUrls: ['/app.componenet.css'],
providers :[GeoService]
})
export class AppComponent {
title = 'Angular2 google map test';
lat: number = 51.673858;
lng: number = 7.815982;
zoom: number = 8;
markers: marker[] = [
{
lat: 51.673858,
lng: 7.815982,
label: 'A',
draggable: true
},
{
lat: 51.373858,
lng: 7.215982,
label: 'B',
draggable: false
},
{
lat: 51.723858,
lng: 7.895982,
label: 'C',
draggable: true
}
];
location: string;
findLocation(): void {
this.result= this.geoService.getLocation(this.location);
}
constructor(private geoService: GeoService) {
}
clickedMarker(label: string, index: number) {
}
mapClicked($event: MouseEvent) {
}
markerDragEnd(m: marker, $event: MouseEvent) {
console.log('dragEnd', m, $event);
}
}
// tslint:disable-next-line:class-name
interface marker {
lat: number;
lng: number;
label?: string;
draggable: boolean;
}
how to get the result in app.component.ts?
findLocation(): void {
this.result= this.geoService.getLocation(this.location);
}
Hopefully you are not still stuck on this. While this might no longer help you, hopefully it will help someone else. Here is what I did just now. First change the getLocation function to this. This is for the current Angular2 release.
getLocation(term: string):Promise<any> {
return this.http.get('http://maps.google.com/maps/api/geocode/json?address=' + term + 'CA&sensor=false')
.toPromise()
.then((response) => Promise.resolve(response.json()));
.catch((error) => Promise.resolve(error.json()));
}
And then in app.component.ts, change it to this.
findLocation(): void {
this.geoService.getLocation(this.location)
.then((response) => this.result = response.results[0])
.catch((error) => console.error(error));
}
I added some error control because that is always good to have. And I had a results array return inside response so clarify with the user which address they want if there is more than one returned.
angular 7.1.4 httpclient is used. getLocation returns obserable
location.service.ts renamed GeoService.ts
import { Injectable } from "#angular/core";
import { HttpClient } from "#angular/common/http";
import { Observable } from "rxjs";
#Injectable({
providedIn: "root"
})
export class LocationService {
constructor(private http: HttpClient) {}
getLocation(term: string): Observable<any> {
return this.http.get(
"http://maps.google.com/maps/api/geocode/json?address=" +
term +
"CA&sensor=false&key=API_KEY"
);
}
}
location.component.ts
/// <reference types="#types/googlemaps" />
import { Component, OnInit, AfterContentInit, ViewChild } from "#angular/core";
import { LocationService } from "../location.service";
declare let google: any;
#Component({
selector: "app-location",
templateUrl: "./location.component.html",
styleUrls: ["./location.component.scss"],
providers: [LocationService]
})
export class LocationComponent implements OnInit {
#ViewChild("gmap") gmapElement: any;
map: google.maps.Map;
latitude: number;
longitude: number;
marker: google.maps.Marker;
locationStr: string;
public result: any;
countMarkers = 0;
constructor(public geoService: LocationService) {}
ngOnInit() {
this.setCurrentPosition();
// tslint:disable-next-line:prefer-const
let mapProp = {
center: new google.maps.LatLng(0, 0),
zoom: 18,
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableDefaultUI: true
};
this.map = new google.maps.Map(this.gmapElement.nativeElement, mapProp);
}
setCenter(e: any) {
e.preventDefault();
this.map.setCenter(new google.maps.LatLng(this.latitude, this.longitude));
}
setCurrentPosition() {
navigator.geolocation.getCurrentPosition(position => {
console.log("Set position", position.coords);
this.latitude = position.coords.latitude;
this.longitude = position.coords.longitude;
this.map.setCenter(new google.maps.LatLng(this.latitude, this.longitude));
const location = new google.maps.LatLng(this.latitude, this.longitude);
this.map.panTo(location);
if (!this.marker) {
this.marker = new google.maps.Marker({
position: location,
map: this.map,
draggable: false,
title: "You Loation!"
});
this.marker.setLabel("You");
this.marker.setMap(this.map);
} else {
this.marker.setPosition(location);
}
});
}
setMarker(label = ".") {
const location = new google.maps.LatLng(this.latitude, this.longitude);
this.map.panTo(location);
if (!this.marker) {
this.marker = new google.maps.Marker({
position: location,
map: this.map,
draggable: false,
title: "You Loation!"
});
this.marker.setLabel(label);
this.marker.setMap(this.map);
} else {
this.marker.setLabel(label);
this.marker.setPosition(location);
}
}
addMarker(label = "") {
const location = new google.maps.LatLng(this.latitude, this.longitude);
// this.map.panTo(location);
const newMarker = new google.maps.Marker({
position: location,
map: this.map,
draggable: false,
title: "You Loation!"
});
this.countMarkers++;
label = this.countMarkers.toString();
newMarker.setLabel(label);
newMarker.setMap(this.map);
}
findLocation(): void {
this.geoService
.getLocation(this.locationStr)
.subscribe(
(data: any) => (
(this.result = data.results[0].geometry.location),
console.log(data.results[0].geometry.location),
(this.latitude = data.results[0].geometry.location.lat),
(this.longitude = data.results[0].geometry.location.lng),
this.map.setCenter(
new google.maps.LatLng(this.latitude, this.longitude)
),
this.addMarker()
),
(err: any) => console.log(err),
() => console.log("All done getting location.")
);
}
}