Google maps marker not showing up


I am new to google maps API and using the code below. Somehow the marker is not being displayed in the map. I am using google maps API v3.

    .controller('MapCtrl', ['$scope', 
       function MapCtrl($scope) {
           var ll = new google.maps.LatLng(38.895112, -77.036366);
           $scope.mapOptions = {
           center: ll,
           zoom: 12,
           mapTypeId: google.maps.MapTypeId.ROADMAP
           $scope.onMapIdle = function() {
               if ($scope.myMarkers === undefined){    
           var marker = new google.maps.Marker({
           map: $scope.myMap,
           position: ll
           $scope.myMarkers = [marker, ];
          $scope.markerClicked = function(m) {


html code is as below;

<div ng-app='localAdventuresApp'>
    <div ng-controller="MapCtrl">
        <div id="map_canvas" ui-map="myMap" 
        style="height:300px;width:400px;border:2px solid #777777;margin:3px; border:1px solid" 
        ui-event="{'map-idle' : 'onMapIdle()'}"
                <div ng-repeat="marker in myMarkers" ui-map-marker="myMarkers[$index]"
                        ui-event="{'map-click': 'markerClicked(marker)'}">
Problem courtesy of: Newbee


Try the following code

<!DOCTYPE html>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Simple markers</title>
<link href="/maps/documentation/javascript/examples/default.css" rel="stylesheet">
<script src=""></script>
function initialize() {
var myLatlng = new google.maps.LatLng(38.895112,-77.036366);
var mapOptions = {
zoom: 4,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

var marker = new google.maps.Marker({
  position: myLatlng,
  map: map,
  title: 'Hello World!'

google.maps.event.addDomListener(window, 'load', initialize);

<div id="map-canvas"></div>
Solution courtesy of: vinod_vh


In fact, it's for AngularJS + Google MAPS V3 + UI-MAP

If markers are not shown when starting map, it's because map is not still loaded. I founded one solution for solve this problem :

In HTML you declare ui-event with 'map-tilesloaded' witch is trigger by maps event 'tilesloaded':

<div ui-map="myMap" class="map-canvas" 
       ui-event="{'map-tilesloaded': 'maploaded()'}"
<div ng-repeat="marker in myMarkers" ui-map-marker="myMarkers[$index]"
         ui-event="{'map-click': 'openMarkerInfo(marker)'}">

Then in your controller you can add markers :

$scope.maploaded = function() {
    $scope.myMarkers.push(new google.maps.Marker({
        map: $scope.myMap,
        position: new google.maps.LatLng(mylat, mylon)
Discussion courtesy of: user2549726

This recipe can be found in it's original form on Stack Over Flow.