Google maps not showing and centering


#1

Hi I’m developing an ionic app. And I’m trying to show an map of a location.
But the map is not showing from the beginning it show when people click on extra info button.
But it just shows a grey field and the marker is not in the center. this is my code.

currentLocation[‘lat’] = 51;
currentLocation[‘lng’] = 4];
google.maps.event.addDomListener(document.getElementById(“map”), “load”,setMap(currentLocation));

function setMap(location){
var mapOptions = {
zoom: 15,
center: location,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
$scope.map = new google.maps.Map(document.getElementById(“map”), mapOptions);

var marker = new google.maps.Marker({
    map: $scope.map,
    animation: google.maps.Animation.DROP,
    position: location
});
$scope.map.control = {};
$scope.map.center.latitude = location['lat'];
$scope.map.center.longitude =  location['lng'];
console.log($scope.map);

};

this is fired when the view loads, and next part is when people click the button.

$scope.info = function()
{
$scope.map.center.latitude = currentLocation[‘lat’];
$scope.map.center.longitude = currentLocation[‘lng’];
$scope.extraInfo=true;
};