Skip to content
This repository was archived by the owner on Nov 4, 2021. It is now read-only.
This repository was archived by the owner on Nov 4, 2021. It is now read-only.

map not created or on-create not called #14

@yailPeralta

Description

@yailPeralta

I have this error: angular.js:13424 TypeError: Cannot read property 'setCenter' of undefined
at $cordovaGeolocation.getCurrentPosition.then.Dialogs.alert.title (create-spot.controller.js:33)
at processQueue (angular.js:15757)
at angular.js:15773
at Scope.$eval (angular.js:17025)
at Scope.$digest (angular.js:16841)
at angular.js:17064
at completeOutstandingRequest (angular.js:5824)
at angular.js:6100(anonymous function) @ angular.js:13424(anonymous function) @ angular.js:10137processQueue @ angular.js:15765(anonymous function) @ angular.js:15773$eval @ angular.js:17025$digest @ angular.js:16841(anonymous function) @ angular.js:17064completeOutstandingRequest @ angular.js:5824(anonymous function) @ angular.js:6100

And here is the code that i'm using:

`function CreateSpotController($scope, $cordovaGeolocation, Dialogs, $ionicPlatform) {
$scope.showMap = false;

$scope.getCurrentPosition = function (options) {

  $scope.mapCreated = function (map) {
    $scope.map = map;
  };

  options = options || {
    timeout: 10000,
    enableHighAccuracy: false
    //maximumAge: 5000
  };

  $ionicPlatform.ready(function () {

    $cordovaGeolocation
      .getCurrentPosition(options)
      .then(function (position) {
        //show map
        $scope.showMap = true;

        $scope.latitude = position.coords.latitude;
        $scope.longitud = position.coords.longitude;

        $scope.map.setCenter(new google.maps.LatLng(position.coords.latitude, position.coords.longitude));

      }, function(error) {
        // error
        Dialogs.alert({
          title: 'Error',
          message: error,
          buttonName: 'Aceptar'
        });
      });

  });

}; // end getCurrentPosition

} // end CreateSpotController`

can you help me please?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions