试图让我的标记指向另一个页面。 复制了以前解决的案例的答案。仍然不起作用。 带有标记的地图出现OK。即使是标题在那里,但链接不起作用。 保持消息“Uncaught ReferenceError:marker is not defined”。 我在做什么错在这里?跑出想法。
有人可以帮我解决这个问题。 巨大的感谢;谷歌地图自定义标记链接不工作
<script
src="https://maps.googleapis.com/maps/api/js?language=ko&key=AIzaSyA3WDZ1KfeUb_Q-SxtIRE2wZ4RBieuGl7s"
type="text/javascript">
</script>
<script>
function Goog2() {
var mapCanvas = document.getElementById('Google_map');
var mapOptions = {
center: new google.maps.LatLng(45.80257,15.9371),
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(mapCanvas, mapOptions);
var myLatLng0 = new google.maps.LatLng(45.80257,15.9371);
var myLatLng1 = new google.maps.LatLng(45.805455,15.983761);
var myLatLng2 = new google.maps.LatLng(45.738822, 16.068278);
var myLatLng3 = new google.maps.LatLng(45.803816, 15.993573);
var markers = [];
markers[0] = new google.maps.Marker({
position: myLatLng0,
map: map,
url: '/cocohouse/location/CH_location_en.html',
icon: "/images/ariranglogoimage28_2.png",
title: 'Coco House',
});
markers[1] = new google.maps.Marker({
position: myLatLng1,
map: map,
icon: "/images/cocohouse/location/train26.png",
url:"/cocohouse/location/to_CH3_en.html",
title: 'Train Terminal',
});
markers[2] = new google.maps.Marker({
position: myLatLng2,
map: map,
icon: "/images/cocohouse/location/airport32.png",
url:"/cocohouse/location/to_CH1_en.html",
title: 'Airport',
});
markers[3] = new google.maps.Marker({
position: myLatLng3,
map: map,
icon: "/images/cocohouse/location/bus26.png",
url:"/cocohouse/location/to_CH2_en.html",
title: 'Bus Terminal',
});
}
google.maps.event.addDomListener(window, 'load', Goog2);
for (i = 0; i < markers.lenght; i++) {
google.maps.event.addListener(markers[i], 'click', function() {
window.location.href = this.url;
});
}
</script>
“未捕获的ReferenceError:标记没有定义”:你有一个行号? – Thierry
markers.lenght:只是一个错字? markers.length – Thierry
消息出现在.... markers.lenght .....线。当我把#4放在那里时,错误消息向下移动到下一行。 –