1+
2+ < script >
3+ requirejs ( [ 'core/demo.js' ] ) ;
4+ </ script >
5+
6+ <!-- Le loading
7+ ================================================== -->
8+
9+ < div id ="map-l " class ="loadingAnimation " >
10+ < div class ="bowl_ringG ">
11+ < div class ="ball_holderG ">
12+ < div class ="ballG ">
13+ </ div >
14+ </ div >
15+ </ div >
16+ </ div >
17+
18+ <!-- Le directive
19+ ================================================== -->
20+
21+ < section id ="map " ng-non-bindable ng-controller ="MapCtrl ">
22+ < div class ="page-header ">
23+ < h1 > Google Maps</ h1 >
24+ </ div >
25+ < div class ="well ">
26+ < div class ="row ">
27+ < div class ="span3 ">
28+ < h4 > Click to add a marker!</ h4 >
29+ < p > {{zoomMessage}}</ p >
30+ < ul >
31+ < li ng-repeat ="marker in myMarkers ">
32+ < a class ="btn " ng-click ="myMap.panTo(marker.getPosition()) ">
33+ Pan to Marker {{$index}}
34+ </ a >
35+ </ li >
36+ </ ul >
37+
38+ <!-- this is the confusing part. we have to point the map marker directive
39+ at an existing google.maps.Marker object, so it can hook up events -->
40+ < div ng-repeat ="marker in myMarkers " ui-map-marker ="myMarkers[$index] "
41+ ui-event ="{'map-click': 'openMarkerInfo(marker)'} ">
42+ </ div >
43+
44+ < div ui-map-info-window ="myInfoWindow ">
45+ < h1 > Marker</ h1 >
46+ Lat: < input ng-model ="currentMarkerLat "> , Lng: < input ng-model ="currentMarkerLng ">
47+ < a class ="btn btn-primary " ng-click ="setMarkerPosition(currentMarker, currentMarkerLat, currentMarkerLng) "> Set Position</ a >
48+ </ div >
49+ </ div >
50+
51+ <!--Giving the div an id="map_canvas" fix problems with twitter bootstrap affecting
52+ google maps-->
53+ < div id ="map_canvas " ui-map ="myMap " class ="span8 map "
54+ ui-event ="{'map-click': 'addMarker($event)', 'map-zoom_changed': 'setZoomMessage(myMap.getZoom())' } "
55+ ui-options ="mapOptions ">
56+ </ div >
57+ </ div >
58+ </ div >
59+ < h3 > How?</ h3 >
60+ < p class ="alert alert-info "> < i class ="icon-info-sign "> </ i > Remember that you can pass a variable containing an object to < code > ui-event</ code > </ p >
61+ < pre class ="prettyprint linenums " ng-non-bindable >
62+ <h4>Click to add a marker!</h4>
63+ <p>{{zoomMessage}}</p>
64+ <ul>
65+ <li ng-repeat="marker in myMarkers">
66+ <a ng-click="myMap.panTo(marker.getPosition())">Pan to Marker {{$index}}</a>
67+ </li>
68+ </ul>
69+
70+ <!-- this is the confusing part. we have to point the map marker directive
71+ at an existing google.maps.Marker object, so it can hook up events -->
72+ <div ng-repeat="marker in myMarkers" ui-map-marker="myMarkers[$index]"
73+ ui-event="{'map-click': 'openMarkerInfo(marker)'}">
74+ </div>
75+
76+ <div ui-map-info-window="myInfoWindow">
77+ <h1>Marker</h1>
78+ Lat: <input ng-model="currentMarkerLat">, Lng: <input ng-model="currentMarkerLng">
79+ <a ng-click="setMarkerPosition(currentMarker, currentMarkerLat, currentMarkerLng)">Set Position</a>
80+ </div>
81+
82+ <!-- Giving the div an id="map_canvas" fix problems with twitter bootstrap affecting
83+ google maps -->
84+ <div id="map_canvas" ui-map="myMap" class="map"
85+ ui-event="{'map-click': 'addMarker($event)', 'map-zoom_changed': 'setZoomMessage(myMap.getZoom())' }"
86+ ui-options="mapOptions">
87+ </div>
88+
89+ <script>
90+ $scope.myMarkers = [];
91+
92+ $scope.mapOptions = {
93+ center: new google.maps.LatLng(35.784, -78.670),
94+ zoom: 15,
95+ mapTypeId: google.maps.MapTypeId.ROADMAP
96+ };
97+
98+ $scope.addMarker = function($event) {
99+ $scope.myMarkers.push(new google.maps.Marker({
100+ map: $scope.myMap,
101+ position: $event.latLng
102+ }));
103+ };
104+
105+ $scope.setZoomMessage = function(zoom) {
106+ $scope.zoomMessage = 'You just zoomed to '+zoom+'!';
107+ console.log(zoom,'zoomed')
108+ };
109+
110+ $scope.openMarkerInfo = function(marker) {
111+ $scope.currentMarker = marker;
112+ $scope.currentMarkerLat = marker.getPosition().lat();
113+ $scope.currentMarkerLng = marker.getPosition().lng();
114+ $scope.myInfoWindow.open($scope.myMap, marker);
115+ };
116+
117+ $scope.setMarkerPosition = function(marker, lat, lng) {
118+ marker.setPosition(new google.maps.LatLng(lat, lng));
119+ };
120+ </script>
121+
122+ <style>
123+ .map {
124+ height: 400px;
125+ width: 600px;
126+ }
127+ </style>
128+ </ pre >
129+ </ section >
0 commit comments