Skip to content

Commit b14ea70

Browse files
committed
forgot to add a example file
1 parent a381fe4 commit b14ea70

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!DOCTYPE html>
2+
<html ng-app="myApp">
3+
4+
<head>
5+
<title>Dynamic ngMap demo</title>
6+
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
7+
<script src="https://maps.google.com/maps/api/js?sensor=false"></script>
8+
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.js"></script>
9+
<script src="scripts/ng-map.min.js"></script>
10+
<script src="scripts/plunkr.js"></script>
11+
<link rel="stylesheet" href="css/styles.css"></script>
12+
<script id="my-js">
13+
var app = angular.module('myApp', ['ngMap', 'plunkr']);
14+
15+
app.controller('mapController', function($scope, $http, $interval) {
16+
$scope.positions =[ [40.71, -74.21], [40.72, -74.20], [40.73, -74.19],
17+
[40.74, -74.18], [40.75, -74.17], [40.76, -74.16], [40.77, -74.15]];
18+
19+
$interval(function() {
20+
var numMarkers = Math.floor(Math.random() * 4) + 4; //between 4 to 8 markers
21+
var positions = [];
22+
for (i = 0; i < numMarkers; i++) {
23+
var lat = 40.71 + (Math.random() / 100);
24+
var lng = -74.21 + (Math.random() / 100);
25+
positions.push([lat, lng]);
26+
}
27+
$scope.positions = positions;
28+
}, 2000);
29+
});
30+
</script>
31+
<style id="my-css">
32+
map, div[map] {display:block; width:600px; height:400px;}
33+
</style>
34+
</head>
35+
36+
<body>
37+
<h1>Dynamic Markers With ng-repeat</h1>
38+
<hr />
39+
40+
<div id="my-html">
41+
<div ng-controller="mapController">
42+
<map zoom="14" center="[40.71, -74.21]">
43+
<marker ng-repeat="p in positions" position="{{p}}" title="{{p.toString()}}"></marker>
44+
</map>
45+
</div>
46+
</div>
47+
48+
<div ng-include="'source_code.html'" plunkr module-name="myApp"></div>
49+
</body>
50+
</html>

0 commit comments

Comments
 (0)