hello , im very new in ionic , i created a page with maps and how to get latitude and longitude from current position and show in input text
this my home.html :
and this my home.ts
export class HomePage {
@ViewChild(‘map’) mapElement: ElementRef;
map: any;constructor(public navCtrl: NavController, public geolocation: Geolocation) {
}
ionViewDidLoad(){
this.loadMap();
}loadMap(){{
this.geolocation.getCurrentPosition().then((position) => { let usersLocation = { lat: position.coords.latitude, lng: position.coords.longitude }; let latLng = new google.maps.LatLng(usersLocation); let mapOptions = { center: latLng, zoom: 15, mapTypeId: google.maps.MapTypeId.ROADMAP } this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions); }, (err) => { console.log(err); });
}
}addMarker(){
let marker = new google.maps.Marker({
map: this.map,
animation: google.maps.Animation.DROP,
position: this.map.getCenter()
});let content = “
Information!
”;this.addInfoWindow(marker, content);
}
addInfoWindow(marker, content){let infoWindow = new google.maps.InfoWindow({
content: content
});
google.maps.event.addListener(marker, ‘click’, () => {
infoWindow.open(this.map, marker);
});
}
getLocation(){
}
}