of-map显示ui中的部分地图

问题描述 投票:1回答:1

我正在使用ng map和geting ui用于屏幕的一半,但没有在完整的div中使用它enter image description here

var app = angular.module('app', ['ngMap']);

app.controller('ctrl', ['$scope', 'ngMap','$timeout', function($scope, ngMap,$timeout) {
  NgMap.getMap().then(function(map) {
    var center = map.getCenter();
    google.maps.event.trigger(map, "resize");
    map.setCenter(center);
  });
  $timeout(function() {
    NgMap.getMap().then(function(map) {
      google.maps.event.trigger(map, 'resize');
    });
  }, 500);
}]);
#ng-map {
  width: 100% !important;
  height: 100% !important;
  position: absolute !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<div ng-app="app" ng-controller="ctrl">
  <div map-lazy-load="https://maps.google.com/maps/api/js" id="ng-map" map-lazy-load-params="https://maps.google.com/maps/api/js?key=AIzaSyB4qnR0XX1tetbLUxSSLVWKi_E4WzGi1tk">
    <ng-map zoom="4">

    </ng-map>
  </div>
</div>

我不知道为什么我会收到这个错误。请帮助我

angularjs google-maps angular-google-maps ng-map
1个回答
2
投票

首先,我相信你是在错误的元素上设置你需要在你的#ng-map div中的元素上设置它尝试将你的CSS改为(也尝试不使用!importants):

#ng-map ng-map{
  width: 100%;
  height: 100%;
  position: absolute;
}

之后,您可以尝试设置:

default-style="false"

在你的ng-map指令中,也尝试使用内联样式,这里是一个例子:

<ng-map zoom="4" default-style="false">
</ng-map>

和plunker:http://plnkr.co/edit/Qh2O0W?p=preview

© www.soinside.com 2019 - 2024. All rights reserved.