Administrator
2022-09-14 58d006e05dcf2a20d0ec5367dd03d66a61db6849
提交 | 用户 | 时间
58d006 1 <!DOCTYPE html>
A 2 <html>
3 <head>
4   <meta charset="utf-8">
5   <title>GMaps.js &mdash; Polygons</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, path, paths;
13     $(document).ready(function(){
14       map = new GMaps({
15         el: '#map',
16         lat: -12.040397656836609,
17         lng: -77.03373871559225,
18         click: function(e){
19           console.log(e);
20         }
21       });
22
23       paths = [
24                 [
25                   [
26                     [-105.00432014465332, 39.74732195489861],
27                     [-105.00715255737305, 39.74620006835170],
28                     [-105.00921249389647, 39.74468219277038],
29                     [-105.01067161560059, 39.74362625960105],
30                     [-105.01195907592773, 39.74290029616054],
31                     [-105.00989913940431, 39.74078835902781],
32                     [-105.00758171081543, 39.74059036160317],
33                     [-105.00346183776855, 39.74059036160317],
34                     [-105.00097274780272, 39.74059036160317],
35                     [-105.00062942504881, 39.74072235994946],
36                     [-105.00020027160645, 39.74191033368865],
37                     [-105.00071525573731, 39.74276830198601],
38                     [-105.00097274780272, 39.74369225589818],
39                     [-105.00097274780272, 39.74461619742136],
40                     [-105.00123023986816, 39.74534214278395],
41                     [-105.00183105468751, 39.74613407445653],
42                     [-105.00432014465332, 39.74732195489861]
43                   ],[
44                     [-105.00361204147337, 39.74354376414072],
45                     [-105.00301122665405, 39.74278480127163],
46                     [-105.00221729278564, 39.74316428375108],
47                     [-105.00283956527711, 39.74390674342741],
48                     [-105.00361204147337, 39.74354376414072]
49                   ]
50                 ],[
51                   [
52                     [-105.00942707061768, 39.73989736613708],
53                     [-105.00942707061768, 39.73910536278566],
54                     [-105.00685214996338, 39.73923736397631],
55                     [-105.00384807586671, 39.73910536278566],
56                     [-105.00174522399902, 39.73903936209552],
57                     [-105.00041484832764, 39.73910536278566],
58                     [-105.00041484832764, 39.73979836621592],
59                     [-105.00535011291504, 39.73986436617916],
60                     [-105.00942707061768, 39.73989736613708]
61                   ]
62                 ]
63               ];
64
65       path = [[-12.040397656836609,-77.03373871559225], [-12.040248585302038,-77.03993927003302], [-12.050047116528843,-77.02448169303511], [-12.044804866577001,-77.02154422636042]];
66
67       map.drawPolygon({
68         paths: paths,
69         useGeoJSON: true,
70         strokeColor: '#131540',
71         strokeOpacity: 0.6,
72         strokeWeight: 6
73       });
74
75       map.drawPolygon({
76         paths: path,
77         strokeColor: '#131540',
78         strokeOpacity: 0.6,
79         strokeWeight: 6
80       });
81     });
82   </script>
83 </head>
84 <body>
85   <h1>GMaps.js &mdash; Polygons</h1>
86   <div class="row">
87     <div class="span11">
88       <div id="map"></div>
89     </div>
90     <div class="span6">
91       <p>You can add polygons in GMaps.js this way:</p>
92       <pre>path = [[-12.040397656836609,-77.03373871559225], [-12.040248585302038,-77.03993927003302], [-12.050047116528843,-77.02448169303511], [-12.044804866577001,-77.02154422636042]];
93
94 map.drawPolygon({
95   paths: path,
96   strokeColor: '#131540',
97   strokeOpacity: 0.6,
98   strokeWeight: 6
99 });</pre>
100       <p>The path of the polygon is defined by an array of array of two (latitude and longitude).</p>
101       <p><span class="label notice">NOTE:</span> Also, you can add a GeoJSON Polygon or MultiPolygon path using <code>useGeoJSON: true</code>.</p>
102     </div>
103   </div>
104 </body>
105 </html>