ng-map shows partial map in ui

时间:2017-12-18 07:26:05

标签: angularjs google-maps angular-google-maps ng-map

I am using ng map and geting ui for half of the screen but not geting it in full 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>

i dont know why i am geting this error .Please help me

1 个答案:

答案 0 :(得分:2)

First thing is I believe you are setting it on wrong element you need to set it up on element inside your #ng-map div try changing you CSS to (also try not to use !importants):

exp

After that, you can try setting up:

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

on your ng-map directive, also try with inline styles, here's example:

default-style="false"

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

相关问题