0

地图工作正常,但是当我尝试添加标记时它不起作用?

到目前为止,这是我的代码:

<script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false"></script>

<script>
    function initialize()
     {var mapProp = {

center: new google.maps.LatLng(-33.975618,25.585858),
zoom:15,
panControl:true,
zoomControl:true,
mapTypeControl:true,
scaleControl:true,
streetViewControl:true,
overviewMapControl:true,
rotateControl:true,    
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("column2linksmap2"),mapProp);

 var marker = new google.maps.Marker({
  position: latLng,
  title:"Hello World!",
  visible: true
 });
  marker.setMap(map);


 }
  google.maps.event.addDomListener(window, 'load', initialize);

</script>
4

3 回答 3

0
function initialize() {
    var Latlng = new google.maps.LatLng(-25.363882,131.044922);

    var mapOptions = {
        zoom: 4,
        center: myLatlng
    }

    var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

    var marker = new google.maps.Marker({
     position: Latlng,
      map: map,
      title: 'Hello World!'
  });
}

google.maps.event.addDomListener(window, 'load', initialize);

问题是你没有声明latlng

于 2013-12-11T09:14:57.380 回答
0
- var marker = new google.maps.Marker({ 
  position: (Give lat & long
   here),   title:"Hello World!",   visible: true  });  
   marker.setMap(map);

你可能会错过给 latLng

于 2014-03-06T11:02:31.803 回答
0
  position: latLng

你在某处声明 latLng 吗?

于 2013-08-04T22:54:01.253 回答