Error run in iPhone

Hello everyone !!!
Now i have a app mobile ionic v1 and use HTML5 Geolocation for maps. It’s running OK on android device real but not on iPhone.

  • Description : When i click into item “FINDING MEDICAL PROVIDERS” so it was supposed to run function “get current user location” but somehow the screen does not display the templates, eventhough there was some signs the this function is still playing, but when click back button so the templates is display and turn off right now…
    I need some help from everyone. The below is clip i test on the emulator iPhone. Link youtube…

And this is log of Xcode…

54%20AM

“Error in Succress callbackId: Geolocation1135109385 : TypeError: null is not an object (evaluating ‘a.firstChild’)”

are there someone help me ?..

Try ionic serve in Safari, maybe there is an error only Safari logs in its console

can you post the relevant code snippets? And don’t be afraid to log things to debug your code.

this is my Controller…

.controller(‘MapCurrentCtrl’,function($scope,$compile,$state,$rootScope){
var directionsDisplay = new google.maps.DirectionsRenderer;
var directionsService = new google.maps.DirectionsService;
var pos,infowindow;
var markers=[];
var MARKER_PATH = ‘https://developers.google.com/maps/documentation/javascript/images/marker_green’;
// Get geo coordinates

function getMapLocation() {

//Button "Find me"
$scope.myPlaces = function(){
          $scope.map.setCenter(pos);
          $scope.map.setZoom(15);
}

navigator.geolocation.getCurrentPosition
(onMapSuccess, onMapError, { enableHighAccuracy: false });

}

// Success callback for get geo coordinates

var onMapSuccess = function (position) {
getMap(position.coords.latitude, position.coords.longitude);

}

// Get map by using coordinates
function getMap(latitude, longitude) {

pos = new google.maps.LatLng(latitude,longitude);

    var mapOptions = {
          center: pos,
          zoom: 13,
          mapTypeControl: false,
          streetViewControl: false,
          zoomControl: true,
              zoomControlOptions: {
                  position: google.maps.ControlPosition.RIGHT_CENTER
              }
        };

$scope.map = new google.maps.Map(document.getElementById('hospitalmap'),
  mapOptions);

//Add searchbox panel into maps
$scope.map.controls[google.maps.ControlPosition.RIGHT_CENTER].push(document.getElementById('btnGetCurrent'));
$scope.map.controls[google.maps.ControlPosition.LEFT_BOTTOM].push(document.getElementById('DirDistancePanel'));

marker = new google.maps.Marker({
  position : pos,
  map : $scope.map,
  title : 'You are here !!!...'
});

var request = {
      location: pos,
      radius: 500,
      types: ['hospital']
    };

    infowindow = new google.maps.InfoWindow();
    var service = new google.maps.places.PlacesService($scope.map);
    service.nearbySearch(request, callback);
  // var itemTitles = $rootScope.hospitallists.map(function(items){
  //   return items.title;
  // });

  function callback(results,status) {
    if(status == google.maps.places.PlacesServiceStatus.OK){
      for (var i = 0; i < results.length; i++) {
        createMarker(results[i]);
      }
    }
  }

    function createMarker(place) {

      var totalDist;
      var totalTime;
      var marker = new google.maps.Marker({
        map: $scope.map,
        icon: 'img/icon-findingmedicalproviders.png',
        position: place.geometry.location
      });
        //Sự kiện click vào marker xung quanh
        google.maps.event.addListener(marker, 'click', function() {
        //Chỉ dẫn đường
        directionsService.route({
        origin: pos,
        destination: place.geometry.location,
        travelMode: 'DRIVING'
      }, function(response, status) {
        if (status === 'OK') {
          directionsDisplay.setDirections(response);
          directionsDisplay.setMap($scope.map);
          directionsDisplay.setOptions( { suppressMarkers: true } );
          
          var myroute = response.routes[0];
        for (i = 0; i < myroute.legs.length; i++) {
          totalDist = myroute.legs[i].distance.value;
          totalTime = myroute.legs[i].duration.value;
        }
        
        //Mở khung info
        var request = {
            reference: place.reference
        };
        

        service.getDetails(request, function(details, status) {
          var contentString = '<div><strong>'+
            details.name +'</strong></br>'+
            details.formatted_address +'</br>'+
            details.website +'</br>'+
            details.formatted_phone_number+'</br>'+
            'Khoảng cách : '+totalDist+'m'+'</br>'+'</br>'+
            '<button ng-click="btnBooking()" style="background-color: #154897;border: none;color: white;text-align: center;">Booking</button></div>';
          var compiled = $compile(contentString)($scope);

          infowindow.setContent(compiled[0]);
          infowindow.open($scope.map, marker);
          $scope.btnBooking = function(){
            $state.go('app.medicalconcierge');
        }
        });
        
        } else {
          window.alert('Tên bệnh viện không được để trống');
        }
      });
      });

    }

}

// Success callback for watching your changing position

var onMapWatchSuccess = function (position) {

var updatedLatitude = position.coords.latitude;
var updatedLongitude = position.coords.longitude;

if (updatedLatitude != Latitude && updatedLongitude != Longitude) {

    Latitude = updatedLatitude;
    Longitude = updatedLongitude;

    getMap(updatedLatitude, updatedLongitude);
}

}

// Error callback

function onMapError(error) {
console.log('code: ’ + error.code + ‘\n’ +
'message: ’ + error.message + ‘\n’);
switch (error.code) {
case error.PERMISSION_DENIED:
alert(‘Người dùng không cho phép định vị’);
break;
case error.POSITION_UNAVAILABLE:
alert(‘Không định vị được thông tin vị trí’);
break;
case error.TIMEOUT:
alert(‘Quá thời gian cho phép’);
break;
}
}

// Watch your changing position

function watchMapPosition() {

return navigator.geolocation.watchPosition
(onMapWatchSuccess, onMapError, { enableHighAccuracy: false });

}

getMapLocation();
})

app.js

.run(function($ionicPlatform) {

$ionicPlatform.ready(function() {
  document.addEventListener("deviceready", onDeviceReady, false);
  function onDeviceReady() {
    StatusBar.hide();
  }
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if (window.cordova && window.cordova.plugins.Keyboard) {
  cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false);

}
if (window.StatusBar) {
  // org.apache.cordova.statusbar required
  StatusBar.styleDefault();
}
});

})

my config

INSMART need permission access to get maps