0
第一:英語不是我的語言,但我嘗試:-)谷歌地圖API:如何將我自己的標記添加到地圖?
我喜歡有標記的地圖。 不帶標識的地圖上工作得很好,你可以在這裏看到:map without markers
的代碼只是簡單:
<!DOCTYPE html>
<html>
<head>
<title>MyRange Driving Ranges world wide </title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=yes" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 30px; padding: 0px }
#map_canvas { height: 80% }
</style>
<script type="text/javascript"
src="https://maps.google.com/maps/api/js?sensor=true">
</script>
<script type="text/javascript">
function initialize() {
var latlng = new google.maps.LatLng(51.1601369818597, 6.72036588191986);
var myOptions = {
zoom: 16,
center: latlng,
mapTypeId: google.maps.MapTypeId.HYBRID
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
//var image = 'http://myrange.de/support/images/flag_red_big.png';
//var myLatLng = new google.maps.LatLng(51.1601369818597, 6.72036588191986));
//var golfMarker = new google.maps.Marker({ position: myLatLng,map: map, icon: image });
}
</script>
</head>
<body onload="initialize()">
<div align="center" id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>
一切工作正常。如果我刪除//比我得到一個空的屏幕:-( 什麼是錯在這3條線?
var image = 'http://myrange.de/support/images/flag_red_big.png';
var myLatLng = new google.maps.LatLng(51.1601369818597, 6.72036588191986));
var golfMarker = new google.maps.Marker({ position: myLatLng,map: map, icon: image });
我希望你能從德國 hape42
理解我的「英語」問候
哦,我的上帝,我看了幾個小時:-(非常感謝! – Hape42 2012-08-07 12:19:30
如果我的答案有幫助,那麼不要忘記接受/ upvote !!! – Neji 2012-08-07 12:20:52