hjg
2024-07-09 30304784e82d4bba24121328da8eb8490aec4f4f
提交 | 用户 | 时间
58d006 1 <!DOCTYPE html>
A 2 <html>
3   <head>
4     <meta charset="utf-8">
5     <title>Styled Maps</title>
6     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
7     <script src="http://maps.google.com/maps/api/js?sensor=true"></script>
8     <script 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>
12         $(function () {
13           var map = new GMaps({
14           el: "#map",
15           lat: 41.895465,
16           lng: 12.482324,
17           zoom: 5, 
18           zoomControl : true,
19           zoomControlOpt: {
20             style : "SMALL",
21             position: "TOP_LEFT"
22           },
23           panControl : true,
24           streetViewControl : false,
25           mapTypeControl: false,
26           overviewMapControl: false
27         });
28         
29         var styles = [
30             {
31               stylers: [
32                 { hue: "#00ffe6" },
33                 { saturation: -20 }
34               ]
35             }, {
36                 featureType: "road",
37                 elementType: "geometry",
38                 stylers: [
39                     { lightness: 100 },
40                     { visibility: "simplified" }
41               ]
42             }, {
43                 featureType: "road",
44                 elementType: "labels",
45                 stylers: [
46                     { visibility: "off" }
47               ]
48             }
49         ];
50         
51         map.addStyle({
52             styledMapName:"Styled Map",
53             styles: styles,
54             mapTypeId: "map_style"  
55         });
56         
57         map.setStyle("map_style");
58       });
59     </script>
60   </head>
61   <body>
62     <h1>GMaps.js style extension - Styled Maps</h1>
63     <div class="row">
64       <div class="span11">
65         <div id="map"></div>
66       </div>
67       <div class="span6">
68         <p>You can easily manage a map style using GMaps.js:</p>
69         <pre> var styles = [
70   {
71     featureType: "road",
72     elementType: "geometry",
73     stylers: [
74       { lightness: 100 },
75       { visibility: "simplified" }
76     ]
77   }, {
78     ...
79   }
80 ];
81
82 map.addStyle({
83     styledMapName:"Styled Map",
84     styles: styles,
85     mapTypeId: "map_style"  
86 });
87
88 map.setStyle("map_style");</pre>
89         <p><span class="label notice">Note: </span>You can choose <strong>different styles</strong> and associate the styled map with the <strong>MapTypeId</strong> and set it to display.</p>
90       </div>
91     </div>
92   </body>
93 </html>