Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70439

I have problem in using google map in ionic

$
0
0

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

Read full topic


Viewing all articles
Browse latest Browse all 70439

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>