I have started an ionic app for work, and one of the features of the cross platform arm is integrating a a Google map api. Currently I am focusing on mostly android side.
So far I had no issues with ionic framework and generally really enjoying. But right now I face a brick wall with trying to get google map working.
To give some details I am currently trying to get a JavaScript API v3 working with the app, and it works fine when I test it in the browser, no issues. But when I run on android device, and crashes and gives me a “Black Screen Of Death”. I cant do anything about. I tried googling the issues, and there is little to find about the solution, what I noticed though is that the issues is common. But the solution is not precise, no concrete work around.
I have tried looking into integrating cordova for this, and it’s still giving me issues. Since I am new and a noob at this, I got little knowledge on how to go about this.
Please help me out!!!
This are some code that is giving me errors
angular.module('myDrive', ['ionic', "angular-data.DSCacheFactory", "google-maps".ns()]) // 'starter.services', 'starter.controllers'
.run(function($ionicPlatform, DSCacheFactory) {
$ionicPlatform.ready(function() {
// 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(true);
}
if(window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
//var div = document.getElementById("map_canvas");
//var map = plugin.google.maps.Map.getMap(div);
DSCacheFactory("leagueDataCache", { storageMode: "localStorage", maxAge: 5000, deleteOnExpire: "aggressive"});
DSCacheFactory("leaguesCache", { storageMode: "localStorage", maxAge: 5000, deleteOnExpire: "aggressive"});
DSCacheFactory("myTeamsCache", { storageMode: "localStorage"});
DSCacheFactory("staticCache", { storageMode: "localStorage"});
});
})
View for the map
<ion-view title="Location Map" ng-controller="LocationMapCtrl as vm">
<ion-content class="has-header">
<ui-gmap-google-map draggable="true" center="vm.map.center" zoom="vm.map.zoom">
</ui-gmap-google-map>
</ion-content>
</ion-view>
Controller for the map
(function() {
'use strict';
// Aim of the conntroller is to screate $scope. $scope is used to communicate with the view
angular.module('myDrive').controller('LocationMapCtrl', ['$stateParams', LocationMapCtrl]);
function LocationMapCtrl($stateParams) {
var vm = this;
vm.locationId = Number($stateParams.id);
vm.map = {
center: {
latitude: 55.418192,
longitude: 10.382617,
},
zoom : 16
};
vm.marker = { }
};
})();
And this is the error that log cat is giving me
Error: [$injector:modulerr] Failed to instantiate module uiGmapgoogle-maps due to:
11-22 14:51:12.833 I/chromium(24024): Error: [$injector:nomod] Module 'uiGmapgoogle-maps' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure t
hat you specify the dependencies as the second argument.
Error: [$injector:modulerr] Failed to instantiate module uiGmapgoogle-maps due to:
11-22 14:51:12.833 I/chromium(24024): Error: [$injector:nomod] Module 'uiGmapgoogle-maps' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure t
hat you specify the dependencies as the second argument.
http://errors.angularjs.org/1.2.25/$injector/modulerr?p0=uiGmapgoogle-maps&p1=Error%3A%20%5B%24injector%3Anomod%5D%20Module%20'uiGmapgoogle-maps'%20is%20not%20a
vailable!%20You%20either%20misspelled%20the%20module%20name%20or%20forgot%20to%20load%20it.%20If%20registering%20a%20module%20ensure%20that%20you%20specify%20the%20dependencies%20as%20the%20second%20a
rgument.%0Ahttp%3A%2F%2Ferrors.angularjs.org%2F1.2.25%2F%24injector%2Fnomod%3Fp0%3DuiGmapgoogle-maps%0A%20%20%20%20at%20file%3A%2F%2F%2Fandroid_asset%2Fwww%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A7703%
3A12%0A%20%20%20%20at%20file%3A%2F%2F%2Fandroid_asset%2Fwww%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A9302%3A17%0A%20%20%20%20at%20ensure%20(file%3A%2F%2F%2Fandroid_asset%2Fwww%2Flib%2Fionic%2Fjs%2Fionic
.bundle.js%3A9226%3A38)%0A%20%20%20%20at%20module%20(file%3A%2F%2F%2Fandroid_asset%2Fwww%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A9300%3A14)%0A%20%20%20%20at%20file%3A%2F%2F%2Fandroid_asset%2Fwww%2Flib%
2Fionic%2Fjs%2Fionic.bundle.js%3A11503%3A22%0A%20%20%20%20at%20forEach%20(file%3A%2F%2F%2Fandroid_asset%2Fwww%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A7950%3A18)%0A%20%20%20%20at%20loadModules%20(file%3
A%2F%2F%2Fandroid_asset%2Fwww%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A11497%3A5)%0A%20%20%20%20at%20file%3A%2F%2F%2Fandroid_asset%2Fwww%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A11504%3A40%0A%20%20%20%20a
t%20forEach%20(file%3A%2F%2F%2Fandroid_asset%2Fwww%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A7950%3A18)%0A%20%20%20%20at%20loadModules%20(file%3A%2F%2F%2Fandroid_asset%2Fwww%2Flib%2Fionic%2Fjs%2Fionic.bu
ndle.js%3A11497%3A5)
Index Page
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">
-->
<!-- JQuery Libs (Loading from google api) -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>window.jQuery||document.write('<scrpt:src="../bower_components/jquery.min.js"><\/script>')</script>
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<!-- Lodash Lib -->
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/0.10.0/lodash.min.js"></script>
<!-- Chacing Lib -->
<script src="lib/angular-cache/dist/angular-cache.min.js"></script>
<!-- Google Maps -->
<script src="https://maps.googleapis.com/maps/api/js?key=###&sensor=false"></script>
<script src='https://maps.googleapis.com/maps/api/js?sensor=false'></script>
<script src="lib/angular-google-maps/dist/angular-google-maps.min.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
<!-- your app's js -->
<script src="app/app.js"></script>
<script src="js/controllers.js"></script>
<script src="app/car/car-log-ctrl.js"></script>
<script src="app/home/home-ctrl.js"></script>
<script src="app/settings/settings-ctrl.js"></script>
<script src="app/car_service/car-service-ctrl.js"></script>
<script src="app/login/login-ctrl.js"></script>
<script src="app/location/location-map-ctrl.js"></script>
<script src="app/services/myDriveApi.js"></script>
I got to say that the documentation on this error is very much lacking in the AngularJS documentation.
As for the API key, do I just stick with using the Google map JS api key, or I also need to generate one for android and put it into the android manifest file? Or I only need it if I go cordova route? Which way is better? (So far both seems to be just as bothersome, and in reality this shouldn’t be difficult.)