blog-angular-ui-map-markers

HTML

<script src="http://maps.googleapis.com/maps/api/js?sensor=false&amp;.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js"></script>
<script src="http://www.flocations.com/static/vendor/angular-ui/map/ui-map.min.js"></script>
<script src="http://www.flocations.com/static/vendor/angular-ui/event/event.js"></script>
<div ng-app='maptesting'>
    <div ng-controller="MapCtrl">
  <iframe src="http://maps.google.com/maps?q=28.628454, 77.376945&z=15&output=embed" width="360" height="270" frameborder="0" style="border:0" ng-disabled='true'></iframe>

        <div id="map_canvas" ui-map="myMap" 
        style="height:300px;width:400px;border:2px solid #777777;margin:3px; border:1px solid" 
        ui-options="mapOptions" 
        ui-event="{'map-idle' : 'onMapIdle()'}"
        >
        </div>
        
        <!--In addition to creating the markers on the map, div elements with existing google.maps.Marker object should be created to hook up with events -->
        <div ng-repeat="marker in myMarkers" ui-map-marker="myMarkers[$index]"
                        ui-event="{'map-click': 'markerClicked(marker)'}">
        </div>
    </div>
</div>

CSS

iframe {
  width: 100vw;
  height: 50vh;
  pointer-events:none;
}

JavaScript

//Add the requried module 'angular-ui' as a dependency
angular.module('maptesting', ['ui.map','ui.event']);

function MapCtrl($scope) {
    var ll = new google.maps.LatLng(28.628454,77.376945);
    $scope.mapOptions = {
        center: ll,
        zoom: 15,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    //Markers should be added after map is loaded
    $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) {
        window.alert("clicked");
    };

}