I’m trying to get the location via geolocation and center the map, but i receive the error “not a LatLng”, someone know why?
export class HomePage{
constructor (private geolocation:Geolocation,
){}
ngOnInit(){
initMap(this.getLocation);
this.getLocation();
}
getLocation(){
var rta: LatLng;
rta = this.geolocation.getCurrentPosition();
console.log('rta: ', rta);
return rta;
}
}
function initMap(position) {
const myLatLng = position;
console.log('posicao: ', myLatLng);
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 16,
center: myLatLng
});
map.addListener('click', function(e) {
placeMarkerAndPanTo(e.latLng, map);
});
}
function placeMarkerAndPanTo(latLng, map) {
var marker = new google.maps.Marker({
position: latLng,
map: map
});
map.panTo(latLng);
}