Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
- <meta charset="utf-8">
- <title>Marker Clustering</title>
- <style>
- #map {
- height: 100%;
- }
- html, body {
- height: 100%;
- margin: 0;
- padding: 0;
- }
- </style>
- </head>
- <body>
- <div id="map"></div>
- <script>
- function getRandom(){
- var min = 40;
- var max = 60;
- return Math.random()*(max-min)+min;
- }
- function initMap() {
- var map = new google.maps.Map(document.getElementById('map'), {
- zoom: 10,
- center: {lat: 56.002853, lng: 53.013463}
- });
- var labels = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
- var markers = locations.map(function(location, i) {
- return new google.maps.Marker({
- position: location,
- label: labels[i % labels.length]
- });
- });
- var markerCluster = new MarkerClusterer(map, markers,
- {imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'});
- }
- var locations = [];
- for(i = 0; i < 1000;i++) locations[i] = {lat: getRandom(), lng: getRandom()};
- </script>
- <script src="https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js">
- </script>
- <script async defer
- src="https://maps.googleapis.com/maps/api/js?key=AIzaSyA-NSNd-dQHRqtBWly7zA92nue6-d6HrPU&callback=initMap">
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment