配置 angular-google-maps with ionic-framework

config angular-google-maps with ionic-framework

我已经为工作启动了一个 ionic 应用程序,跨平台臂的功能之一是集成了一个 Google 地图 api。目前我选择angular-google-maps

现在我尝试像这样用 ionic 配置它:

似乎一切都很好,但为什么它不起作用?

<html ng-app="appMaps">
  <head>
    <meta charset="utf-8">
    <title>Map</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
    <script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>
    <script src='//maps.googleapis.com/maps/api/js?sensor=false'></script>
    <script src="https://raw.github.com/lodash/lodash/3.10.1/lodash.min.js"></script>
    <script src="https://raw.github.com/angular-ui/angular-google-maps/master/dist/angular-google-maps.min.js"></script>

  </head>
  <body>
    <ion-header-bar class="bar-dark" >
      <h1 class="title">Google Maps Example</h1>
    </ion-header-bar>
    <ion-content>
      <div id="map_canvas" ng-controller="mainCtrl">
         <ui-gmap-google-map center="map.center" zoom="map.zoom" options="options"></ui-gmap-google-map>
      </div>
    </ion-content>

    <SCRIPT>
    angular.module('appMaps', ['uiGmapgoogle-maps','ionic'])
    .controller('mainCtrl', function($scope) {
        $scope.map = {center: {latitude: 51.219053, longitude: 4.404418 }, zoom: 14 };
        $scope.options = {scrollwheel: false};
    });
    </SCRIPT>
  </body>
</html>

你错过了一些东西:

这是工作片段:

<html ng-app="appMaps">

<head>
  <meta charset="utf-8">
  <title>Map</title>
  <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
  <link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
  <script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>
  <script src="//rawgit.com/lodash/lodash/3.10.1/lodash.min.js"></script>
  <script src='//maps.googleapis.com/maps/api/js?sensor=false'></script>
  <script src="//rawgit.com/nmccready/angular-simple-logger/master/dist/angular-simple-logger.js"></script>
  <script src="//rawgit.com/angular-ui/angular-google-maps/master/dist/angular-google-maps.min.js"></script>
  <style>
  #map_canvas {
  width: 100%;
  height: 100%;
}

.angular-google-map-container { height: 400px; }
    
  </style>
</head>

<body>
  <ion-header-bar class="bar-dark">
    <h1 class="title">Google Maps Example</h1>
  </ion-header-bar>
  <ion-content>
    <div id="map_canvas" ng-controller="mainCtrl">
      <ui-gmap-google-map center="map.center" zoom="map.zoom" options="map.options"></ui-gmap-google-map>
    </div>
  </ion-content>

  <SCRIPT>
    angular.module('appMaps', ['uiGmapgoogle-maps', 'ionic'])
      .controller('mainCtrl', function($scope) {
        $scope.map = {
          center: {
            latitude: 51.219053,
            longitude: 4.404418
          },
          zoom: 14,
          options: {
            scrollwheel: false
          }
        };
      });
  </SCRIPT>
</body>

</html>