Alternative to Cordova Geolocation Plugin for getting current position

Hi Everyone,

I’m new to Ionic and developing an app integrating with Google Map API. My code is working well on browser but I need to install cordova geolocation to make the function navigator.geolocation.getCurrentPosition works on Android Device (Nexus 5) (cordova plugin add

Do you have any suggestion to improve this? Since I dont really understand how cordova geolocation plugin works and why I need it for my app :smile:

This is my codes:

/* ========== Transaction Page ========== */
<ion-view view-title="Transaction History" ng-controller="TransactionController">
  <div class="bar bar-header map-div">
    <div id="map"></div>
  <ion-content scroll="true" class="transaction">

/* ========== Transaction Page Controller ========== */
.controller('TransactionController', function($scope, $state, $ionicLoading, $stateParams) {
  $scope.accountNumber = $stateParams.accountNumber;
  $scope.productName = $stateParams.productName;

  $scope.drawMap = function() {
    var myLatlng = new google.maps.LatLng(144.94623769999998, -37.8216962);

    var mapOptions = {
      center: myLatlng,
      zoom: 13

    $ = new google.maps.Map(document.getElementById("map"),

    // Try HTML5 geolocation
    if (navigator.geolocation) {
      console.log("Device supports Geolocation");
      navigator.geolocation.getCurrentPosition(function(position) {
        console.log("Enter getCurrentPosition");
        var pos = new google.maps.LatLng(position.coords.latitude,

        var myLocation = new google.maps.Marker({
          position: pos,
          map: $,
          content: 'Your location'
    } else {
      // Browser doesn't support Geolocation
      console.log("Device doesn't support Geolocation");