Javascript 谷歌地图标记未显示API v3

Javascript 谷歌地图标记未显示API v3,javascript,google-maps-api-3,Javascript,Google Maps Api 3,标记器没有出现,我看了文件,但我找不到问题,有人能帮我吗 以下是js: function initialize() { var mapOptions = { center: new google.maps.LatLng(-8.064903, -34.896872), zoom: 16, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google

标记器没有出现,我看了文件,但我找不到问题,有人能帮我吗

以下是js:

function initialize() {
      var mapOptions = {
        center: new google.maps.LatLng(-8.064903, -34.896872),
        zoom: 16,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      };
      var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);

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

我猜您的
位置
对象没有定义。尝试将标记位置设置为与地图中心相同的板条,并查看其是否有效:

function initialize() {
  latLng = new google.maps.LatLng(-8.064903, -34.896872)
  var mapOptions = {
    center: latLng,
    zoom: 16,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);

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

我刚刚创建了var location=newgoogle.maps.LatLng(-8.064903,-34.896872);成功了!谢谢@拉蒙瓦斯康塞洛斯太棒了!如果答案解决了你的问题,别忘了接受,祝你在GMAP上好运!