我在两个选项卡中使用 ng map。加载时显示带有两个选项卡地址的标记。如果一旦标记在控制台中显示错误。我正在尝试但无法解决。Onload 我想在两个选项卡上显示带有(信息窗口)地址的标记。
<!doctype html>
<html ng-app="ui.bootstrap.demo">
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script src="https://maps.google.com/maps/api/js?libraries=placeses,visualization,drawing,geometry,places"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-animate.js"></script>
<script src="https://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.js"></script>
<script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-1.2.5.js"></script>
<script>
angular.module('ui.bootstrap.demo', ['ngAnimate', 'ui.bootstrap', 'ngMap']);
angular.module('ui.bootstrap.demo').controller('TabsDemoCtrl', function ($scope, $window, $timeout) {
this.address = "Toronto Canada";
$scope.reRednerMap = function() {
$timeout(function() {
angular.forEach($scope.maps, function(index) {
google.maps.event.trigger(index, 'resize');
});
}, 500);
}
$scope.maps = [];
$scope.$on('mapInitialized', function(evt, evtMap) {
$scope.maps.push(evtMap);
});
$scope.reRednerMap();
});
</script>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<style type="text/css">
form.tab-form-demo .tab-pane {
margin: 20px 20px;
}
</style>
<div ng-controller="TabsDemoCtrl">
<uib-tabset active="active">
<uib-tab index="0" heading="tab 1" select="reRednerMap()">
<ng-map center="13.0222427,80.1745555"" zoom="12" style="width:600px; height:400px">
<marker position="13.0222427,80.1745555" on-click="map.showInfoWindow('bar1')">
</marker>
<info-window id="bar1">
<div ng-non-bindable>
<div>channi Tamil nadu</div>
</div>
</info-window>
</ng-map>
</uib-tab>
<uib-tab index="1" heading="tab 2" select="reRednerMap()">
<ng-map center="13.0222427,80.1745555"" zoom="12" style="width:600px; height:400px">
<marker id="current_marker" position="13.0222427,80.1745555" on-click="map.showInfoWindow('bar')">
</marker>
<info-window id="bar">
<div ng-non-bindable>
<div>channi CMBT</div>
</div>
</info-window>
</ng-map>
</uib-tab>
</uib-tabset>
</div>
</body>
</html>