I am trying to initalize google maps in the application I am writing, I am using the places api for some of the functionalities which is working fine, Now I am trying to show a map on a page but the map never shows up. i do not get any error on the console when I use the following code.
index.html
<script src="https://maps.googleapis.com/maps/api/js?key=mykey&libraries=places"></script>
mapview.html
<div ng-controller="MapViewController as mapctrl" ng-init="initialize()">
<div class="container">
<div class="row">
<div id="map"></div>
</div>
<div ui-view></div>
</div>
</div>
mapViewController.js
(function(angular) {
angular.module('myapp').controller('MapViewController', ['$state','$http','$stateParams','$window','$route','$document','$localStorage','$scope','$location', function($state,$http,$stateParams,$window,$route,$document,$localStorage,$scope,$location) {
$scope.initialize = function(){
console.log("log");
var mapOptions = {
zoom: 11,
center: {lat: -34.397, lng: 150.644},
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map'), mapOptions);
};
}]);
})(angular)
I get the log message when the contoller is initialized but the map doesn't show on the page. I would like to know how can I make it possible without using any directive.
app-module
code? Also, did you defineng-app
? Also, did you giveheight and width
to yourmap id
? – AndreaM16 Sep 13 at 11:39