提交 | 用户 | 时间
|
58d006
|
1 |
<!DOCTYPE html> |
A |
2 |
<html> |
|
3 |
<head> |
|
4 |
<meta charset="utf-8"> |
|
5 |
<title>GMaps.js — 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 |
$(document).ready(function(){ |
|
14 |
map = new GMaps({ |
|
15 |
el: '#map', |
|
16 |
lat: -12.043333, |
|
17 |
lng: -77.028333, |
|
18 |
mapTypeControlOptions: { |
|
19 |
mapTypeIds : ["hybrid", "roadmap", "satellite", "terrain", "osm", "cloudmade"] |
|
20 |
} |
|
21 |
}); |
|
22 |
map.addMapType("osm", { |
|
23 |
getTileUrl: function(coord, zoom) { |
|
24 |
return "http://tile.openstreetmap.org/" + zoom + "/" + coord.x + "/" + coord.y + ".png"; |
|
25 |
}, |
|
26 |
tileSize: new google.maps.Size(256, 256), |
|
27 |
name: "OpenStreetMap", |
|
28 |
maxZoom: 18 |
|
29 |
}); |
|
30 |
map.addMapType("cloudmade", { |
|
31 |
getTileUrl: function(coord, zoom) { |
|
32 |
return "http://b.tile.cloudmade.com/8ee2a50541944fb9bcedded5165f09d9/1/256/" + zoom + "/" + coord.x + "/" + coord.y + ".png"; |
|
33 |
}, |
|
34 |
tileSize: new google.maps.Size(256, 256), |
|
35 |
name: "CloudMade", |
|
36 |
maxZoom: 18 |
|
37 |
}); |
|
38 |
map.setMapTypeId("osm"); |
|
39 |
}); |
|
40 |
</script> |
|
41 |
</head> |
|
42 |
<body> |
|
43 |
<h1>GMaps.js — Map Types</h1> |
|
44 |
<div class="row"> |
|
45 |
<div class="span11"> |
|
46 |
<div id="map"></div> |
|
47 |
</div> |
|
48 |
<div class="span6"> |
|
49 |
<p>You can define many map types from external map services, like OpenStreetMap:</p> |
|
50 |
<pre>map.addMapType("osm", { |
|
51 |
getTileUrl: function(coord, zoom) { |
|
52 |
return "http://tile.openstreetmap.org/" + zoom + "/" + coord.x + "/" + coord.y + ".png"; |
|
53 |
}, |
|
54 |
tileSize: new google.maps.Size(256, 256), |
|
55 |
name: "OpenStreetMap", |
|
56 |
maxZoom: 18 |
|
57 |
});</pre> |
|
58 |
<p>You must define a function called <code>getTileUrl</code>, which returns a tile URL according the coordenates in the map.</p> |
|
59 |
</div> |
|
60 |
</div> |
|
61 |
</body> |
|
62 |
</html> |