This repository has been archived by the owner on Mar 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
map.html
66 lines (59 loc) · 1.73 KB
/
map.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css" media="screen">
html { height:100%; }
body { height:100%; margin:0; padding:0; }
#map_canvas { width:100%; height:100%; }
div.info { font-family:Helvetica; font-size:14px; padding:0.5em; }
div.info img { float:left; margin:0 1em 1em 0; border:1px solid #666; }
</style>
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
</head>
<body>
<div id="map_canvas"></div>
<script type="text/javascript">
var map;
var markers = [];
function createMarker(id, name, lat, lng, icon) {
var pos = new google.maps.LatLng(lat, lng);
if(markers[id]) {
markers[id].setPosition(pos);
} else {
markers[id] = new google.maps.Marker({position:pos, map:map, title:name, icon:icon});
var infowindow = new google.maps.InfoWindow({
content: name
});
google.maps.event.addListener(markers[id], 'click', function() {
infowindow.open(map, markers[id]);
});
fitMap();
}
}
function fitMap() {
var bounds = new google.maps.LatLngBounds();
for(k in markers) {
bounds.extend(markers[k].getPosition());
}
map.fitBounds(bounds);
if(map.getZoom() > 12) {
map.setZoom(12);
}
}
function viewOnMap(id) {
for(k in markers) {
if(k == id) {
map.panTo(markers[k].getPosition());
}
}
}
function go() {
var latlng = new google.maps.LatLng(0, -90);
var myOptions = { zoom:2, center:latlng, mapTypeId:google.maps.MapTypeId.ROADMAP };
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
go();
</script>
</body>
</html>