Tracking location has become a part and parcel of our daily life. It’s an indispensable tech utilized by major applications in app store ranging from tracking our lost device, food delivery, cab booking, gaming and UPI payments. But implementing it in our own app could be a tedious task which demands excellent coding skills with good understanding about its working. With the advent of low-code platforms location tracking won’t be an intimidating task. By having little understanding about the working we can easily create location tracking apps at faster rate.
In Wavemaker location tracking can be implemented by the following steps:
- Google map integration: The Google map prefab allows users to drag and drop google map in work space. Scroll to prefab section in the left panel. Then drag and drop Google map prefab into the work space.
- Google cloud platform:The functionality part of google map can be achieved through the Google cloud platform. API key has to be generated in credentials section.The API key is then copied to wavemaker tab panel. Then origin and destination fields have to be entered. For this we have to activate google cloud in our account by adding credit card details.
The link for registering google cloud platform is given as follows:
- Direction API:It is used to calculate optimal route between origin and destination points. After activating google cloud go to https://console.developers.google.com and in the left panel select APIs & Services and select dashboard. Now search Direction API from API library and enable it.
- Distance matrix API:It is used to calculate distance and time between origin and destination points.Similarly go to https://console.developers.google.com and in the left panel select APIs & Services and select dashboard. Now search Distance matrix API from API library and enable it.
Sample code for calculating distance between two points is given as follows:
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyD_paxSjUeEJz2a5bJBEdsyIwKAUv6fW1g&libraries=geometry&language=en&callback=initMap" async defer></script>
srcLocation = new google.maps.LatLng(12.9654 , 80.2461 );
dstLocation = new google.maps.LatLng(12.9516 , 80.1462 );
var distance = google.maps.geometry.spherical.computeDistanceBetween(srcLocation, dstLocation)
alert(distance/1000); // Distance in Kms.
<h1>Distance matrix API</h1>
Thus tracking location from source location to destination location can be done easily in less time through wavemaker.