提交 | 用户 | 时间
|
58d006
|
1 |
<!DOCTYPE html> |
A |
2 |
<html> |
|
3 |
<head> |
|
4 |
<meta charset="utf-8"> |
|
5 |
<title>Layers 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&libraries=weather"></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 type="text/javascript"> |
|
12 |
var map; |
|
13 |
$(function () { |
|
14 |
map = new GMaps({ |
|
15 |
el: "#map", |
|
16 |
lat: -12.043333, |
|
17 |
lng: -77.028333, |
|
18 |
zoom: 3 |
|
19 |
}); |
|
20 |
|
|
21 |
map.addLayer('weather', { |
|
22 |
clickable: false |
|
23 |
}); |
|
24 |
map.addLayer('clouds'); |
|
25 |
}); |
|
26 |
</script> |
|
27 |
</head> |
|
28 |
<body> |
|
29 |
<h1>GMaps.js add and remove layers - Layers</h1> |
|
30 |
<div class="row"> |
|
31 |
<div class="span11"> |
|
32 |
<div id="map"></div> |
|
33 |
</div> |
|
34 |
<div class="span6"> |
|
35 |
<p>You can easily add or remove a layer using GMaps.js:</p> |
|
36 |
<pre>var map = new GMaps({ |
|
37 |
el: '#map', |
|
38 |
lat: -12.043333, |
|
39 |
lng: -77.028333 |
|
40 |
}); |
|
41 |
map.addLayer('weather', { |
|
42 |
clickable: false |
|
43 |
}); |
|
44 |
map.addLayer('clouds'); |
|
45 |
</pre> |
|
46 |
<p><span class="label notice">Note: </span> You can choose <strong>different layers</strong>. Possible values are <strong>weather</strong>, <strong>clouds</strong>, <strong>traffic</strong>, <strong>transit</strong> and/or <strong>bicycling</strong></p> |
|
47 |
<p><span class="label notice">Note: </span> Be aware that you have to add the library 'weather' in the url for the weather/clouds layer: <pre>http://maps.google.com/maps/api/js?sensor=true&libraries=weather</pre></p> |
|
48 |
<p><span class="label notice">Note: </span> In the second param you can add your options for the layer as object.</p> |
|
49 |
<p><span class="label notice">Note: </span> To remove a layer you can use <pre>map.removeLayer('clouds');</pre></p> |
|
50 |
|
|
51 |
</div> |
|
52 |
</div> |
|
53 |
</body> |
|
54 |
</html> |