Get the long lat of a certain place


Hi, im new in ionic framework, my problem is im trying to get the longitude and latitude of a certain place, not only my current location, how do i do this?? Can someone give link if this concern is being opened before. or Can i ask for help?

thank you!


hey @harniel1,

Actually to get those information you will need to use google api. but to get good answer you will need to give more information, contextualize your question. For example wich places are you trying to get lng and lat, city, business places. The more clear you’ll be more people could help you easily.



@quieterkali this is my code snippet:

in my AutoCompletePage.ts

import { Component, NgZone } from ‘@angular/core’;
import { IonicPage, NavController, NavParams, ViewController } from ‘ionic-angular’;

import { Geolocation } from ‘@ionic-native/geolocation’;
import { NativeGeocoder, NativeGeocoderReverseResult, NativeGeocoderForwardResult } from ‘@ionic-native/native-geocoder’;

declare var google;

selector: ‘page-autocompletepage’,
templateUrl: ‘autocompletepage.html’,
export class AutocompletepagePage {

// constructor(public navCtrl: NavController, public navParams: NavParams) {
// }

// ionViewDidLoad() {
// console.log(‘ionViewDidLoad AutocompletepagePage’);
// }

autocompleteItems: any = [];
service = new google.maps.places.AutocompleteService();

constructor (public viewCtrl: ViewController, private zone: NgZone, public navCtrl: NavController,
public navParams: NavParams, public geolocation: Geolocation) {
this.autocomplete = {
query: ‘’

dismiss() {

chooseItem(item: any) {

updateSearch() {
if (this.autocomplete.query == ‘’) {
this.autocompleteItems = [];
let me = this;
this.service.getPlacePredictions({ input: this.autocomplete.query, componentRestrictions: {country: ‘PH’} }, function (predictions, status) {
// if (status != google.maps.places.PlacesServiceStatus.OK) {
// alert(status);
// return;
// }
me.autocompleteItems = []; () {
predictions.forEach(function (prediction) {


in the registerPage.ts

showAddressModal () {
let modal = this.modalCtrl.create(AutocompletepagePage);
let me = this;
modal.onDidDismiss(data => { = data;


im trying to get the lng lat of the result of this, what ever the place the user input: how can i get the long lat of “”? contains the address returned by the autocompletemodal.


I see, the way i will solve this, will be ask user to inform the address of the place he deserve to knowthe lat and lng, with that address i will use google api to get the lat and lng of that place.
Is that help you? Feel free to tell me what you think about this way to solve the problem.


@quieterkali the user will not know the long lat i will store the long lat and store it for database purposes,

ahmm can you post the link for the google api that gets the long lat?

for ionic 3/2. please thank you!


Here is the link:

function geocodeAddress(geocoder, resultsMap) {
        var address = document.getElementById('address').value;
        geocoder.geocode({'address': address}, function(results, status) {
          if (status === 'OK') {
            var marker = new google.maps.Marker({
              map: resultsMap,
              position: results[0].geometry.location
          } else {
            alert('Geocode was not successful for the following reason: ' + status);

You just need to understand the code and use it at your convenience :slight_smile:

Hope that will help


@quieterkali thank you very much for your time and hellp :slight_smile: it really worked!!


you’re welcome, it’s lways good to help :slight_smile:


Hey i am trying to display country name from latitude and longitude using reverse geocoding. Will you please help me do it