提交 | 用户 | 时间
|
58d006
|
1 |
<!DOCTYPE html> |
A |
2 |
<html> |
|
3 |
<head> |
|
4 |
<meta charset="utf-8"> |
|
5 |
<title>GMaps.js — Marker Clusterer</title> |
|
6 |
<script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclusterer/1.0/src/markerclusterer.js"></script> |
|
7 |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> |
|
8 |
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script> |
|
9 |
<script type="text/javascript" src="../gmaps.js"></script> |
|
10 |
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.3.0/bootstrap.min.css" /> |
|
11 |
<link rel="stylesheet" type="text/css" href="examples.css" /> |
|
12 |
<script type="text/javascript"> |
|
13 |
var map; |
|
14 |
$(document).ready(function(){ |
|
15 |
map = new GMaps({ |
|
16 |
div: '#map', |
|
17 |
lat: -12.043333, |
|
18 |
lng: -77.028333, |
|
19 |
markerClusterer: function(map) { |
|
20 |
return new MarkerClusterer(map); |
|
21 |
} |
|
22 |
}); |
|
23 |
|
|
24 |
var lat_span = -12.035988012939503 - -12.050677786181573; |
|
25 |
var lng_span = -77.01528673535154 - -77.04137926464841; |
|
26 |
|
|
27 |
for(var i = 0; i < 100; i++) { |
|
28 |
var latitude = Math.random()*(lat_span) + -12.050677786181573; |
|
29 |
var longitude = Math.random()*(lng_span) + -77.04137926464841; |
|
30 |
|
|
31 |
map.addMarker({ |
|
32 |
lat: latitude, |
|
33 |
lng: longitude, |
|
34 |
title: 'Marker #' + i |
|
35 |
}); |
|
36 |
} |
|
37 |
}); |
|
38 |
</script> |
|
39 |
</head> |
|
40 |
<body> |
|
41 |
<h1>GMaps.js — Marker Clusterer</h1> |
|
42 |
<div class="row"> |
|
43 |
<div class="span11"> |
|
44 |
<div id="map"></div> |
|
45 |
</div> |
|
46 |
<div class="span6"> |
|
47 |
<p>With GMaps.js you can use a marker clusterer to group large amount of markers:</p> |
|
48 |
<pre>map = new GMaps({ |
|
49 |
div: '#map', |
|
50 |
lat: -12.043333, |
|
51 |
lng: -77.028333, |
|
52 |
markerClusterer: function(map) { |
|
53 |
return new MarkerClusterer(map); |
|
54 |
} |
|
55 |
});</pre> |
|
56 |
<p>You can use MarkerClusterer or MarkerClustererPlus. If you want to use a custom marker clustering library, you have to define a <code>addMarker</code> method.</p> |
|
57 |
<p><span class="label notice">Note:</span> Read more about MarkerClusterer and MarkerClustererPlus <a href="http://code.google.com/p/google-maps-utility-library-v3/wiki/Libraries">here</a>.</p> |
|
58 |
</div> |
|
59 |
</div> |
|
60 |
</body> |
|
61 |
</html> |