i am using the code below for google map but when i clicked to map returned inaccurate
latitude and longitude
please tell me if there any problem
currentlocation() {
setTimeout(() => {
this.getGoogleMaps()
.then(googleMaps => {
this.geolocation.getCurrentPosition().then((resp) => {
this.lat = resp.coords.latitude;
this.lng = resp.coords.longitude;
const mapEl = this.mapElementRef.nativeElement;
const mapitem = new googleMaps.Map(mapEl, {
center: { lat: resp.coords.latitude, lng: resp.coords.longitude },
zoom: 17
});
googleMaps.event.addListenerOnce(mapitem, ‘idle’, () => {
this.renderer.addClass(mapEl, ‘visible’);
});
let marker = new googleMaps.Marker({
position: { lat: resp.coords.latitude, lng: resp.coords.longitude },
map: mapitem,
title: ‘’,
draggable: true
});
this.markers.push(marker);
mapitem.addListener(‘click’, event => {
this.setMapOnAll();
this.lat = event.latLng.lat();
this.lng = event.latLng.lng();
marker = new googleMaps.Marker({
position: event.latLng,
map: mapitem,
title: ‘’,
draggable: true
});
this.markers.push(marker);
});
marker.addListener(‘drag’, event => {
this.lat = event.latLng.lat();
this.lng = event.latLng.lng();
});
});
})
.catch(err => {
console.log(err);
});
}, 0);
}
1 post - 1 participant