Please any body help what is wrong in my code I try to spend so many hours but could resolve I also remove plugin after that install plugin but not map show in ios while my api key also currect please please help thanks in advance
config
$scope.getposition = function() {
debugger;
// $state.go(“mapPosition”);
$state.go(“mapPosition”, { obj: $scope.$parent.$parent.caf, forwardUrl: “createcaf.step3” });
}
‘use strict’;
angular.module(‘NotaryGuardApp’)
.controller(‘MapCtrl’, function($scope, $rootScope, $state, $stateParams, $ionicHistory,$ionicPopup) {
debugger;
// $ionicHistory.clearCache([$state.current.name]).then(function() {
// $state.reload();
// });
$scope.$on('$ionicView.enter', function(e) {
debugger;
$scope.position = null;
$("#map_canvas").html("");
$scope.backView = $ionicHistory.backView().stateName;
$scope.mapLoadinit();
})
$scope.mapLoadinit = function() {
$notaryguard.maps.init("map_canvas", function(position) {
debugger;
$scope.position = {
Latitude: position.lat,
Longitude: position.lng
};
},
function(err) {
debugger;
$ionicPopup.alert({
title: "Error",
template: "Map could not be rendered."
});
}
);
}
$scope.confirm = function() {
debugger;
$stateParams.obj.Position = $scope.position;
$scope.position = null;
$state.go($stateParams.forwardUrl);
}
$scope.goBack = function() {
debugger;
$scope.position = null;
$state.go($scope.backView);
}
});
'‘use strict’;
(function() {
// var helpermapService = function($ionicPopup, $ionicLoading) {
// var mapserviceInstance = {};
var map;
var fnLocationSuccess;
var fnLocationErr;
//var onDeviceReady = function(fnSuccess, fnError) {
var onDeviceReady = function() {
debugger;
var div = document.getElementById("map_canvas");
map = plugin.google.maps.Map.getMap(div);
map.setMapTypeId(plugin.google.maps.MapTypeId.HYBRID);
// map.addEventListener(plugin.google.maps.event.MAP_READY, onMapReady(fnSuccess, fnError));
map.addEventListener(plugin.google.maps.event.MAP_READY, onMapReady);
//$scope.onCreate({ map: map });
};
// var onMapReady = function(fnSuccess, fnError) {
var onMapReady = function() {
debugger;
function onSuccess(position) {
debugger;
var currentPosition = new plugin.google.maps.LatLng(position.coords.latitude, position.coords.longitude);
// map.remove();
// map.event.trigger(map, 'resize');
map.moveCamera({
'target': currentPosition,
'zoom': 17,
'tilt': 30
});
map.addMarker({
'position': currentPosition,
'myMsg': 'Hello'
});
//fnSuccess(position);
fnLocationSuccess(currentPosition);
};
function onError(error) {
debugger;
fnLocationErr(error.message);
//fnError(error.message);
// alert('code: ' + error.code + '\n' +
// 'message: ' + error.message + '\n');
}
//var options = { timeout: 31000, enableHighAccuracy: true, maximumAge: 90000 };
var watchID = navigator.geolocation.getCurrentPosition(onSuccess, onError);
};
$notaryguard.maps = {
//setTimeout(function(){
init: function(id, fnSuccess, fnError) {
debugger;
fnLocationSuccess = fnSuccess;
fnLocationErr = fnError;
document.addEventListener("deviceready", onDeviceReady, false);
}
// },1000);
}