1

我的角度模块:

我使用了 ng-map 指令,在这里输入了坐标:

angular.module('ngMap').controller('mapCtrl', function ($scope) {
    //Open Modal Function
    $scope.open = function() { //Open Modal Function
        $('#warningModal').modal('show');
    }
    $scope.vm={data:[],position:[]};
    $scope.vm.data = [
      { foo: 1, bar: 1 },
      { foo: 2, bar: 2 },
      { foo: 3, bar: 3 },
      { foo: 4, bar: 4 },
      { foo: 5, bar: 5 },
      { foo: 6, bar: 6 },
      { foo: 7, bar: 7 }
    ];
    $scope.vm.positions = [
      { pos: [40.71, -74.21] },
      { pos: [40.72, -74.20] },
      { pos: [40.73, -74.19] },
      { pos: [40.74, -74.18] },
      { pos: [40.75, -74.17] },
      { pos: [40.76, -74.16] },
      { pos: [40.77, -74.15] }
    ];
});

HTML:

我使用了两种样式,第一种是 html 地图,第二种是模态地图。地图在 html 中工作,但其他没有运行。

<div ng-controller="mapCtrl">

<button class="btn btn-default" ng-click="open()">Open map!</button>

<div id="warningModal" class="modal fade">
    <div class="modal-dialog  modal-sm" style="padding-top: 40px;">
        <div class="panel panel-primary">
            <div class="panel-heading">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="panel-title" id="voteLabel"><span class="glyphicon glyphicon-remove"></span></h4>
            </div>
            <div class="modal-body">
                <ng-map zoom="11" center="[40.74, -74.18]">
                    <marker ng-repeat="p in vm.positions"
                            position="{{p.pos}}"
                            data="{{data[$index]}}"
                            on-click="showData()" 
                            title="pos: {{p.pos}}"></marker>
                </ng-map>
            </div>
        </div>
    </div>
</div>
<ng-map zoom="11" center="[40.74, -74.18]">
    <marker ng-repeat="p in vm.positions"
            position="{{p.pos}}"
            data="{{data[$index]}}"
            on-click="showData()" ;
            title="pos: {{p.pos}}"></marker>
</ng-map>

Plunker 链接: http ://embed.plnkr.co/LHzOQL930BqVco6gQhqX/

4

1 回答 1

4

似乎模态中的地图没有被初始化,因为模态display: none;最初有。添加此css后:

.modal {
  display: block;
  z-index: -1;
}

.modal.fade.in {
  z-index: 1050;
}

出现模态地图。

于 2016-01-09T13:24:48.470 回答