Administrator
2022-09-14 58d006e05dcf2a20d0ec5367dd03d66a61db6849
提交 | 用户 | 时间
58d006 1 <!DOCTYPE html>
A 2 <html>
3 <head>
4   <meta charset="utf-8">
5   <title>GMaps.js &mdash; Overlay Map Types</title>
6   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
7   <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
8   <script type="text/javascript" src="../gmaps.js"></script>
9   <link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.3.0/bootstrap.min.css" />
10   <link rel="stylesheet" type="text/css" href="examples.css" />
11   <script type="text/javascript">
12     var map;
13
14     var getTile = function(coord, zoom, ownerDocument) {
15       var div = ownerDocument.createElement('div');
16       div.innerHTML = coord;
17       div.style.width = this.tileSize.width + 'px';
18       div.style.height = this.tileSize.height + 'px';
19       div.style.background = 'rgba(250, 250, 250, 0.55)';
20       div.style.fontFamily = 'Monaco, Andale Mono, Courier New, monospace';
21       div.style.fontSize = '10';
22       div.style.fontWeight = 'bolder';
23       div.style.border = 'dotted 1px #aaa';
24       div.style.textAlign = 'center';
25       div.style.lineHeight = this.tileSize.height + 'px';
26       return div;
27     };
28
29     $(document).ready(function(){
30       map = new GMaps({
31         el: '#map',
32         lat: -12.043333,
33         lng: -77.028333
34       });
35       map.addOverlayMapType({
36         index: 0,
37         tileSize: new google.maps.Size(256, 256),
38         getTile: getTile
39       });
40     });
41   </script>
42 </head>
43 <body>
44   <h1>GMaps.js &mdash; Overlay Map Types</h1>
45   <div class="row">
46     <div class="span11">
47       <div id="map"></div>
48     </div>
49     <div class="span6">
50       <p>You can define many overlay map types this way:</p>
51       <pre>var getTile = function(coord, zoom, ownerDocument) {
52   var div = ownerDocument.createElement('div');
53   div.innerHTML = coord;
54   div.style.width = this.tileSize.width + 'px';
55   div.style.height = this.tileSize.height + 'px';
56   div.style.background = 'rgba(250, 250, 250, 0.55)';
57   div.style.fontFamily = 'Monaco, Andale Mono, Courier New, monospace';
58   div.style.fontSize = '10';
59   div.style.fontWeight = 'bolder';
60   div.style.border = 'dotted 1px #aaa';
61   div.style.textAlign = 'center';
62   div.style.lineHeight = this.tileSize.height + 'px';
63   return div;
64 };
65
66 map.addOverlayMapType({
67   index: 0,
68   tileSize: new google.maps.Size(256, 256),
69   getTile: getTile
70 });</pre>
71       <p>You must define a function called <code>getTile</code>, which returns a HTML element used to fill the map overlay. Also, you have to set an overlay <code>index</code>, which place the overlay on top of the base map, according this index.</p>
72       <p><span class="label notice">NOTE:</span> You can remove an overlay map type using <code>removeOverlayMapType(overlay_index)</code>.</p>
73     </div>
74   </div>
75 </body>
76 </html>