0
我有一個用於從joshmorony.com進行映射的演示程序。當我將工廠引入控制器時,它會完全停止渲染。下面的工作來顯示地圖,但如果我將控制器行更改爲標記爲FAIL的控制器行,則它不會通過仿真器進行渲染。任何想法爲什麼?我從Visual Studio 2015年向控制器添加工廠時不呈現簡單離子應用程序
// Ionic Starter App
// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
angular.module('starter', ['ionic', 'ngCordova'])
.run(function ($ionicPlatform) {
$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) {
StatusBar.styleDefault();
}
})
})
.config(function ($stateProvider, $urlRouterProvider) {
$stateProvider
.state('map', {
url: '/',
templateUrl: 'templates/map.html',
controller: 'MapCtrl'
});
$urlRouterProvider.otherwise("/");
})
.factory('JMGoogleMaps', function($cordovaGeolocation) {
function initMap(){
};
})
**// FAILS to render at all...
// .controller('MapCtrl', function ($scope, $state, $cordovaGeolocation, JMGoogleMaps) {**
.controller('MapCtrl', function ($scope, $state, $cordovaGeolocation) {
var options = { timeout: 10000, enableHighAccuracy: true };
$cordovaGeolocation.getCurrentPosition(options).then(function (position) {
var latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
var mapOptions = {
center: latLng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
$scope.map = new google.maps.Map(document.getElementById("map"), mapOptions);
//Wait until the map is loaded
google.maps.event.addListenerOnce($scope.map, 'idle', function() {
var marker = new google.maps.Marker({
map: $scope.map,
animation: google.maps.Animation.DROP,
position: latLng
});
var infoWindow = new google.maps.InfoWindow({
content: "Here I am!"
});
google.maps.event.addListener(marker, 'click', function() {
infoWindow.open($scope.map, marker);
});
});
}, function (error) {
console.log("Could not get location");
});
});