我有史密森尼航空和太空博物馆地图的代码,Google上的地图有多层可用,还有一个选择器,可让您在它们之间切换。
有没有办法让这个选择器显示在我的地图上? 码: 编辑:较旧的帖子没有解决我的问题,谷歌已经为此更新了v3?
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Google Maps Multiple Markers</title>
<script src="http://maps.google.com/maps/api/js?key=AIzaSyARP6gVN4t8LL9pD-KtM3DCJbxWY4KSUUY&sensor=false"
type="text/javascript"></script>
</head>
<body>
<div id="map" style="width: 600px; height: 600px;"></div>
<script type="text/javascript">
var locations = [
['Smithsonian National Air and Space Museum', 38.88815, -77.01985],
['Lockheed Martin IMAX Theater', 38.888342, -77.019492]
];
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 18,
center: new google.maps.LatLng(38.88758,-77.01998),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,
icon:'https://chart.googleapis.com/chart?chst=d_map_pin_letter&chld='+ (i + 1) +'|50C9F8|000000',
shadow:'https://chart.googleapis.com/chart?chst=d_map_pin_shadow'
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}
</script>
</body>
</html>
最终目标是能够在多个楼层设置标记,如果可能的话,我想将其实现到现有代码中。