2013-03-25 101 views
0

爲什麼我的標記不出現?
我也試過沒有行「marker.show」,但標記似乎不出現。標記不顯示在地圖api V3

<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: Custom Control</title> 
<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"> </script> 
<script type="text/javascript" src="ZoomPanControl.js"></script> 
<script type="text/javascript"> 
function initialize() { 
    var myOptions = { 
     zoom: 10, 
     center: new google.maps.LatLng(47.3732589, 8.2382168), 
     mapTypeId: google.maps.MapTypeId.ROADMAP, 
     navigationControl: true } 
    var map = new google.maps.Map(document.getElementById('map_canvas'), myOptions); 
    var marker = new google.maps.Marker({ position: google.maps.LatLng(47.3732589, 8.2382168), title: 'x', map:map}); 
    marker.show; 
}; 
</script></head> 
<body style="margin:0px; padding:0px;" onload="initialize()"> 
<div id="map_canvas" style="width:100%; height:100%"></div> 
</body></html> 

回答

6

這應該做的伎倆:

var marker = new google.maps.Marker(); 
marker.setPosition(new google.maps.LatLng(47.3732589, 8.2382168)); 
marker.setMap(map); 
+0

不用擔心!如果這個答案幫助你,請註冊並接受爲答案。 – chriz 2013-03-26 13:38:47

4

你接近,但你將你的position時忘了new關鍵字。它應該是這樣的:

var marker = new google.maps.Marker({ position: new google.maps.LatLng(47.3732589, 8.2382168), title: 'x', map:map}); 
+0

非常感謝!我搜索了DAYS! – user2190036 2013-03-26 13:37:53