YO! 'Su人:)我是新來的HTML,所以我可以使用一些幫助:) 我一直試圖把谷歌地圖放在頁面頂部,具體高度:500/600px和寬度:100%。那裏沒問題。但是,當我嘗試添加多個標記(作爲URL鏈接n'自定義圖標),他們不顯示出來..當我成功添加標記我的(自動完成嵌入式)搜索欄消失:/有人可以讓我做谷歌地圖嵌入自動完成搜索欄和少數「鏈接」標記?告訴我我做錯了什麼?我已經搜索了一個答案位似乎無法找到它。預先感謝您..不能添加標記到谷歌地圖
如果有人不能讀這個(sry不知道如何格式化這個權利)這裏的鏈接到我的兆豐與html。沒有病毒,請不要威脅。
<https://mega.co.nz/#!8lAi2I4Q!cPb3XJKccd54Qm8QtnBV2QBWt42KVDFzgI89ZnRCBJo>
而這裏的同一代碼的html:
<html>
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false"
type="text/javascript"></script>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <title>Garinfo</title>
<style>
html, body, #map-canvas {
height: 85%;
margin: 0px;
padding: 0px
}
.controls {
margin-top: 16px;
border: 1px solid transparent;
border-radius: 2px 0 0 2px;
-moz-box-sizing: border-box;
height: 32px;
outline: none;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
#pac-input {
background-color: #fff;
padding: 0 11px 0 13px;
width: 400px;
font-family: Roboto;
font-size: 15px;
font-weight: 300;
text-overflow: ellipsis;
}
#pac-input:focus {
border-color: #4d90fe;
margin-left: -1px;
padding-left: 14px; /* Regular padding-left + 1. */
width: 401px;
}
.pac-container {
font-family: Roboto;
}
#type-selector {
color: #fff;
background-color: #4d90fe;
padding: 5px 11px 0px 11px;
}
#type-selector label {
font-family: Roboto;
font-size: 13px;
font-weight: 300;
}
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places"> </script>
<script>
function initialize() {
var map = new google.maps.Map(document.getElementById('map-canvas'), {
center: new google.maps.LatLng(45.242629, 19.827195),
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var input = /** @type {HTMLInputElement} */(
document.getElementById('pac-input'));
map.controls[google.maps.ControlPosition.BOTTOM_CENTER].push(input);
var searchBox = new google.maps.places.SearchBox(
/** @type {HTMLInputElement} */(input));
google.maps.event.addListener(searchBox, 'places_changed', function() {
var places = searchBox.getPlaces();
if (places.length == 0) {
return;
}
for (var i = 0, marker; marker = markers[i]; i++) {
marker.setMap(null);
}
markers = [];
var bounds = new google.maps.LatLngBounds();
for (var i = 0, place; place = places[i]; i++) {
var image = {
url: place.icon,
size: new google.maps.Size(71, 71),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(17, 34),
scaledSize: new google.maps.Size(25, 25)
};
map.fitBounds(bounds);
var location1 = new google.maps.Map.LatLng(45.239115, 19.824766)
var location2 = new google.maps.Map.LatLng(45.244517, 19.847312)
var marker1 = new google.maps.Marker({
position: Location1,
url: 'http://www.facebook.com/',
map: map
});
var marker2 = new google.maps.Marker({
position: Location2,
url: 'http://www.google.com/',
map: map
});
google.maps.event.addListener(marker, 'click', function() {
window.location.href = marker.url;
});
markers.push(marker);
bounds.extend(place.geometry.location);
}
});
google.maps.event.addListener(map, 'bounds_changed', function() {
var bounds = map.getBounds();
searchBox.setBounds(bounds);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<style>
#target {
width: 345px;
}
</style>
</head>
<body onunload="GUnload()">
<script type="text/javascript">
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 15,
center: new google.maps.LatLng(45.239115, 19.824766),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var marker = new google.maps.Marker({
position: map.getCenter(),
url: 'http://www.google.com/',
map: map
});
google.maps.event.addListener(marker, 'click', function() {
window.location.href = marker.url;
});
</script>
<input id="pac-input" class="controls" type="text" placeholder="Search Box">
<div id="map-canvas"></div>
</body>
</html>
我已經計算了基於您的文件通過兆豐下載的行。 –
非常感謝! :d – user3799813