angular-google-maps不能在index.html之外工作

时间:2015-12-14 04:01:38

标签: javascript angularjs google-maps ionic-framework

我正在使用离子+ cordova我尝试了所有的东西,但我没有找到解决方案,并且控制台没有错误。 如果我将我的Geolocation.html标记放在index.html中它工作正常,但在路由/状态更改后它无法正常工作。

的index.html

{:g}

模块配置:

    <!DOCTYPE html>
<html ng-app="myApp">

    <head>
        <meta charset="UTF-8">
        <link rel="stylesheet" href="ionic/css/ionic.min.css"></link>
        <link rel="stylesheet" href="ionic/css/ionicons.min.css"></link>
        <title></title>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8">
        <meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=no">
        <link rel="stylesheet" href="css/app.css">
        <link rel="stylesheet" type="text/css" href="css/index_main.less.css" class="main-less">

        <script src="cordova.js"></script>
        <script type="application/javascript" src="ionic/js/ionic.bundle.js"></script>
        <script type="text/javascript" src="lib/ng-cordova.min.js"></script>

        <script type="text/javascript" src="lib/angular-filter.min.js"></script>

        <script type="text/javascript" src="lib/lodash.min.js"></script>
        <script src="http://rawgit.com/angular-ui/angular-google-maps/2.0.X/dist/angular-google-maps.js"></script>

        <script type="text/javascript" src="js/app.js"></script>
        <script type="text/javascript" src="js/services/constants.js"></script>
        <script type="text/javascript" src="js/services/services.js"></script>
        <script type="text/javascript" src="js/controllers/controllers.js"></script>
    </head>

<body >
    <ion-nav-view></ion-nav-view>
</body>

控制器:

var myApp = angular.module('myApp',['ionic', 'angular.filter', 'uiGmapgoogle-maps', 'ngCordova']);
myApp.config(function($stateProvider, $urlRouterProvider, $compileProvider, uiGmapGoogleMapApiProvider) {
    uiGmapGoogleMapApiProvider.configure({
        v: '3.17',
        libraries: 'weather,geometry,visualization',
        language: 'en',
        sensor: 'false',
      });

    $stateProvider.state('routeGeoLocation', {
    url: '/routeGeoLocation',
    templateUrl:'pages/GeoLocation.html',
  })
});

GeoLocation.html

myApp.controller("GeoLocationController", function($scope, $cordovaGeolocation, uiGmapIsReady){
    $scope.map = {center: {latitude: 60.1451, longitude: -99.6680 }, zoom: 8 };
    $scope.readyForMap = true;
    $scope.control = {};

    uiGmapIsReady.promise().then(function (maps) {
        $scope.map = {center: {latitude: 60.1451, longitude: -99.6680 }, zoom: 8 };
//        $scope.control.refresh();
    });

如果有人提出我做错的地方,那将会有所帮助。 感谢。

0 个答案:

没有答案