This is a step by step tutorial on how to use Cordova Geolocation and Geocoder plugin in an Ionic 4 app to get the current user device position, get current user address.
In this tutorial we are going to learn how to get users device location with latitude and longitude.
We will learn to get the users address using Geolocation and Geocoder Plugins.
We will look at how to add target platforms such as iOS, Android or Windows and create the build in Ionic for various devices.
- Create New Ionic 4 / Angular Project
- Install & Configure Cordova Geolocation and Geocoder Plugins
- Get Current Location Latitude and Longitude
- Get Current Address
- Add Target Platform: Android, iOS or Windows
- Build Your Ionic App
We must have the latest version of Node js installed on our device. If you are not having then follow this tutorial on: How to Download and Install Node.js and npm
Use the command to install Ionic 4 Cordova globally on your machine.
sudo npm install -g cordova ionic
By using the following command, you can check the Ionic CLI version running on your machine.
ionic -v # 5.4.13
Use below command to update Ionic and Cordova.
sudo npm update -g cordova ionic
Let’s start installing a brand new Ionic 4 Angular app with the help of Ionic CLI, run the following command in your terminal.
ionic start ionic-geolocation-app blank --type=angular
Get inside the project folder.
Start the app in the browser.
ionic serve --lab