Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 爱奥尼亚框架不显示谷歌地图_Angularjs_Google Maps_Ionic Framework_Ionic - Fatal编程技术网

Angularjs 爱奥尼亚框架不显示谷歌地图

Angularjs 爱奥尼亚框架不显示谷歌地图,angularjs,google-maps,ionic-framework,ionic,Angularjs,Google Maps,Ionic Framework,Ionic,我正在努力学习爱奥尼亚框架,我被谷歌地图的部分困住了。 我只是想在屏幕上显示一张地图,但是我看到的是一个白色的屏幕。 任何帮助都将不胜感激 以下是我的index.html代码: <!DOCTYPE html> <html ng-app="app"> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1, maximum-sc

我正在努力学习爱奥尼亚框架,我被谷歌地图的部分困住了。 我只是想在屏幕上显示一张地图,但是我看到的是一个白色的屏幕。 任何帮助都将不胜感激

以下是我的index.html代码:

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

    <title>YOE</title>

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

    <script src="lib/ionic/js/ionic.bundle.js"></script>
    <script src="js/controllers.js"></script>
    <script src="js/index.js"></script>
    <script src="cordova.js"></script>
    <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyAJJYLVx6vFBLDO8EUA5RNAPtqIzI27HY0&sensor=true"></script>

  </head>

  <body>
    <ion-nav-bar class="bar-positive">
      <ion-nav-back-button class="button-icon ion-arrow-left-c">
      </ion-nav-back-button>
    </ion-nav-bar>
    <ion-nav-view></ion-nav-view>
  </body>
</html>
controllers.js:

angular.module('app.controllers', [])

.controller('SignInCtrl', function($scope, $state) {

  $scope.signIn = function(user) {
    console.log('Sign-In', user);

    /*

        Authenticate user through Firebase, if authenticated, go to menu.jukebox state.
    */
    $state.go('venues.venueList');
  };
})

.controller('VenuesCtrl', function($scope){

    $scope.hideBackButton = true;
})

.controller('VenueListCtrl', function($scope){

    /*
        Dummy array for venues. It will be changed with the data from the server. 
    */

  $scope.venues = [
    { id: 1, name: 'Lucky Strike San Fransisco', distance: '0.3 km', image: 'http://wtc15.com/sites/wtc15.com/files/cr-collections/7/100x100/valamar-venue1.jpg' },
    { id: 2, name: 'Match', distance: '0.7 km', image: 'http://www.venuereport.com/uploads_cache/venue_tiny/2014/10/Ironside-Oyster-San-Diego-Venue-3.jpg' },
    { id: 3, name: 'Supercell', distance: '0.9 km', image: 'http://www.venuereport.com/uploads_cache/venue_tiny/2014/10/paris-event-venue-4.jpg' },
    { id: 4, name: 'The Melt', distance: '4 km', image: 'http://www.venuereport.com/uploads_cache/venue_tiny/2014/10/belize-wedding-venue-3.jpg' }
  ];
})

.controller('venueMapCtrl', function($scope, $ionicLoading) {
           console.log('map', 'reached that far');

    google.maps.event.addDomListener(window, 'load', function() {

        var myLatlng = new google.maps.LatLng(37.3000, -120.4833);

        var mapOptions = {
            center: myLatlng,
            zoom: 16,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };

        var map = new google.maps.Map(document.getElementById("map"), mapOptions);

        navigator.geolocation.getCurrentPosition(function(pos) {
            map.setCenter(new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude));
            var myLocation = new google.maps.Marker({
                position: new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude),
                map: map,
                title: "My Location"
            });
        });

        $scope.map = map;
    });

});
viouses.html:

<ion-view view-title="Venues" hide-back-button="true">
    <div class="tabs-striped tabs-top tabs-background-positive tabs-color-light">
        <div class="tabs">
          <a class="tab-item active" ui-sref="venues.venueList">
            <i class="icon ion-ios-list"></i>
            List
          </a>
          <a class="tab-item" ui-sref="venues.venueMap">
            <i class="icon ion-map"></i>
                Map
          </a>
        </div>
    </div>
    <ion-nav-view name="venueDetails"></ion-nav-view>
</ion-view>

我在老师的帮助下解决了这个问题。 问题是爱奥尼亚的代码样本。 更好地使用:

google.maps.event.addDomListener(window, 'load', initialize);


我用以下方法解决了这个问题:

angular.element(document).ready(function () {
    //load your map inside this
});
<ion-view view-title="VenueList">
  <ion-content style="padding-top: 50px;">
    <div class="list">

        <a ng-repeat="venue in venues" 
           href="#/{{venue.id}}"
           class="item item-thumbnail-left">

          <img ng-src="{{ venue.image }}">
          <h2>{{ venue.name }}</h2>
          <br>
          <p>{{ venue.distance }}</p>
        </a>

      </div>
  </ion-content>
</ion-view>
.scroll {
    height: 100%;
}

#map {
    width: 100%;
    height: 100%;
}
google.maps.event.addDomListener(window, 'load', initialize);
ionic.Platform.ready(initialize); 
angular.element(document).ready(function () {
    //load your map inside this
});