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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
| <html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps JavaScript API v3 Example: Common Loader</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="utils.js"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/redmond/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script type="text/javascript">
// Set the Map variable
var map;
var all =
[ ["Location 1", "Summerdale Rd", "Elon", "NC", "27253", "36.150491", "-79.5470544"],
["Location 2", "7205 Olmstead Dr", "Burlington", "NC", "27215", "36.069974", "-79.548101"],
["Location 3", "W Market St", "Graham", "NC", "27253", "36.0722225", "-79.4016207"],
["Location 4", "Mt Hermon Rock Creek Rd", "Graham", "NC", "27253", "35.9826328", "-79.4165216"],
["Location 5", "415 Spring Garden St", "Greensboro", "NC", "27401", "36.06761", "-79.794984"]
];
function initialize()
{
var myOptions =
{ zoom: 9,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var infoWindow = new google.maps.InfoWindow;
map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
// Set the center of the map
var pos = new google.maps.LatLng(36.0621881, -79.5101063);
map.setCenter(pos);
setMarkers(map, all)
};
function setMarkers(map, all)
{
for (var i in all)
{ var name = all[i][0];
var address = all[i][1];
var city = all[i][2];
var state = all[i][3];
var zip = all[i][4];
var lat = all[i][5];
var lng = all[i][6];
var latlngset = new google.maps.LatLng(lat, lng);
var marker = new google.maps.Marker({map: map,title: city,position: latlngset });
var contentInfoWindow =
[ '<div id="InfoText">',
'<div class ="tabs">',
'<ul>',
'<li><a href="#tab1">General</a></li>',
'<li><a href="#tab2" id="SV">Street View</a></li>',
'</ul>',
'<div id="tab1">',
'<h3><b>' + name + '</h3></b>',
'<p>' + city + '<BR>' + state + '<BR>' + zip + '</p>',
'</div>',
'<div id="tab2">',
'<div id="pano"><div>',
'</div>',
'</div>'
].join('');
var infoWindowOptions =
{ content : contentInfoWindow, // Ici passe le content dans le constructeur
position : latlngset
};
infowindow = new google.maps.InfoWindow(infoWindowOptions);
google.maps.event.addListener(marker, "click", function()
{ infowindow = new google.maps.InfoWindow(infoWindowOptions);
infowindow.open(map, marker);
var panoramaOptions = {position: marker.position};
google.maps.event.addListener(infowindow, 'domready', function()
{ $(".tabs").tabs();
$('#SV').click(function()
{ var panorama = new google.maps.StreetViewPanorama(document.getElementById("pano"),panoramaOptions);
map.setStreetView(panorama);
});
});
});// Click marker
}// For
};
function infoWinBack(marker, infowindow)
{ return function(){ infowindow.open(map, marker);};
};
// Initializes the Google Map
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<style>
#infotext {
font-size: 12px;
width:480px;
height: 380px;
}
.tabs {
width:450px;
height: 350px;
}
#pano {
width:350px;
height: 250px;
}
</style>
</head>
<body>
<div id="map_canvas" style="width:700px; height:600px"></div>
<!-- <div id='pano' style='position: absolute: top: 40px; left: 2px; width: 380px; height:290px;'></div> -->
</body>
</html> |
Partager