0

私の単純なイオンプロジェクトでは3つの状態があります。ログイン後にホームページにマップを追加したいのですが、テンプレートファイルであるmap.htmlファイルにマップを追加しようとすると、map.htmlをブラウザで開くと表示されます。しかし、$ stateProviderを使用してこの状態(map.html)に到達しようとすると、マップは表示されません。

マイmap.htmlファイルは次のとおりです。

<!DOCTYPE html> 
<html ng-app="starter"> 
    <head> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> 
    <title></title> 

    <link href="lib/ionic/css/ionic.css" rel="stylesheet"> 
    <link href="css/style.css" rel="stylesheet"> 

    <script async defer src="https://maps.googleapis.com/maps/api/js?key=APIKEY&callback=initMap"></script> 


<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> 

    <!-- ionic/angularjs js --> 
    <script src="lib/ionic/js/ionic.bundle.js"></script> 


    <script src="cordova.js"></script> 

    <!-- your app's js --> 
    <script src="js/app.js"></script> 

     <style> 
     html, body { 
     height: 100%; 
     margin: 0; 
     padding: 0; 
     } 
     #map { 
     height: 400px; 
     } 
    </style>  
    </head> 

<body ng-controller="mapctrl"> 
    <ion-header-bar class="bar-dark"> <h1 class="title">Home Page</h1></ion-header-bar> 
    <ion-view> 
     <div id="map" ng-init="initMap()"></div> 
     <button ng-click="goOther()" class="button button-block button-dark">For more detail please click!</button> 
    </ion-view> 
    </body> 
</html> 

マイapp.jsは次のとおりです。

var app =angular.module('starter', ['ionic']) 
app.run(function($ionicPlatform) { 
    $ionicPlatform.ready(function() { 
    if(window.cordova && window.cordova.plugins.Keyboard) { 
     cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); 
     cordova.plugins.Keyboard.disableScroll(true); 
    } 
    if(window.StatusBar) { 
     StatusBar.styleDefault(); 
    } 
    }); 
}) 

app.config(['$stateProvider','$urlRouterProvider',function($stateProvider,$urlRouterProvider){ 
    $stateProvider 
    .state('login',{ 
     url:'/login', 
     templateUrl:'templates/login.html', 
     controller:'loginctrl' 
    }) 
    .state('map',{ 
     url:'/map', 
     templateUrl:'templates/map.html', 
     controller:'mapctrl' 
    }) 
    .state('other',{ 
     url:'/other', 
     templateUrl:'templates/other.html', 
     controller:'otherctrl' 
    }) 

    $urlRouterProvider.otherwise('/login'); 
}]) 

app.controller('loginctrl',function($scope,$state){ 
    $scope.goMap = function(){$state.go('map');}; 
}) 

app.controller('mapctrl',function($scope,$state){ 
    $scope.goOther = function(){ 
     $state.go('other');}; 

     $scope.initMap = function() { 
     console.log("deneme"); 
     var myLatlng = new google.maps.LatLng(51.5120, -0.12); 
     var mapOptions = { 
      zoom: 14, 
      center: myLatlng 
       } 
     var map = new google.maps.Map(document.getElementById("map"), mapOptions); 

     google.maps.event.addDomListener(window, "resize", function() { 
      var center = map.getCenter(); 
      google.maps.event.trigger(map, "resize"); 
      map.setCenter(center); 
     }); 
    }; 
}) 


app.controller('otherctrl',function($scope,$state){ 
    $scope.goLogin = function(){$state.go('login');}; 
}); 

「私もmap.htmlファイルに直接マップを追加しようとしましたが、それはdoesnのどちらも出現する。

ありがとうございます。

+0

を持つ任意の依存関係を持っていない可能性があり、私はあなたの

+0

の内側に含まれないする必要が期待する私が何を含めればよいのですか? – yuhmeteriz

+0

可能な複製http://stackoverflow.com/questions/23975827/uncaught-referenceerror-stateprovider-is-not-defined-angular-ui-router?rq=1 –

答えて

0

グーグルマップはクロームでHTTPSでのみ動作し、それが$ stateProvider

関連する問題