marker-clusterer.html 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <!DOCTYPE html>
  2. <html ng-app="myApp">
  3. <head>
  4. <title>Dynamic ngMap demo</title>
  5. <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
  6. <script src="https://maps.google.com/maps/api/js?sensor=false"></script>
  7. <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.js"></script>
  8. <!-- build:js scripts/ng-map.min.js -->
  9. <script src="../app/scripts/app.js"></script>
  10. <script src="../app/scripts/directives/map_controller.js"></script>
  11. <script src="../app/scripts/directives/map.js"></script>
  12. <script src="../app/scripts/directives/marker.js"></script>
  13. <script src="../app/scripts/directives/shape.js"></script>
  14. <script src="../app/scripts/services/geo_coder.js"></script>
  15. <script src="../app/scripts/services/navigator_geolocation.js"></script>
  16. <script src="../app/scripts/services/attr2_options.js"></script>
  17. <!-- endbuild -->
  18. <script src="https://rawgit.com/allenhwkim/angularjs-google-maps/master/testapp/scripts/markers.js"></script>
  19. <script src="https://rawgit.com/allenhwkim/angularjs-google-maps/master/testapp/scripts/markerclusterer.js"></script>
  20. <script>
  21. var app = angular.module('myApp', ['ngMap']);
  22. app.controller('mapController', function($scope, $http, $interval) {
  23. var map;
  24. $scope.dynMarkers = [];
  25. $scope.$on('mapInitialized', function(event, evtMap) {
  26. map = evtMap;
  27. for (var i=0; i<1000; i++) {
  28. var latLng = new google.maps.LatLng(markers[i].position[0], markers[i].position[1]);
  29. $scope.dynMarkers.push(new google.maps.Marker({position:latLng}));
  30. }
  31. $scope.markerClusterer = new MarkerClusterer(map, $scope.dynMarkers, {});
  32. });
  33. });
  34. </script>
  35. <style>
  36. map, div[map] {display:block; width:600px; height:400px;}
  37. </style>
  38. </head>
  39. <body>
  40. <h1>Marker Cluster</h1>
  41. <hr />
  42. <div ng-controller="mapController">
  43. <map zoom="2" center="[43.6650000, -79.4103000]"></map>
  44. </div>
  45. </body>
  46. </html>