angularjsgoogle-mapsangular-google-mapsng-map

ng-map shows partial map in ui


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


Solution

  • 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):

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

    After that, you can try setting up:

    default-style="false"
    

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

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

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