Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法在Google Maps Api v3中添加标记_Javascript_Google Maps Api 3_Google Maps Markers - Fatal编程技术网

Javascript 无法在Google Maps Api v3中添加标记

Javascript 无法在Google Maps Api v3中添加标记,javascript,google-maps-api-3,google-maps-markers,Javascript,Google Maps Api 3,Google Maps Markers,从昨天开始,我尝试在GoogleMapsAPIv3中添加标记。我阅读了文档和所有的内容。这是我的密码: <script type="text/javascript"> var map; function initialize() { var mapOptions = { center: new google.maps.LatLng(28.63, 77.21), zoom: 8, disableDefaultUI: false,

从昨天开始,我尝试在GoogleMapsAPIv3中添加标记。我阅读了文档和所有的内容。这是我的密码:

<script type="text/javascript">
  var map;
  function initialize() {

    var mapOptions = {

      center: new google.maps.LatLng(28.63, 77.21),
      zoom: 8,
  disableDefaultUI: false,
      mapTypeId: google.maps.MapTypeId.ROADMAP
      };
      map = new google.maps.Map(document.getElementById("map-canvas"),
        mapOptions);


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

  function getFillingDetails(){
    var vehicleId = $('#selectVehicle option:selected').val();
    $.getJSON('getFillingDetails.php', {id : vehicleId}, function(data){
  var lat = [];
  var lon = [];
  var price = [];
  $.each(data, function(key, value){
    lat.push(value.latitude);
    lon.push(value.longitude);
    price.push(value.price);
    });
  });

  var myLatlng = new google.maps.LatLng(23.72,77.10);

var marker = new google.maps.Marker({
            position: new google.maps.LatLng(23.72, 72.100),
            map: map,
        });

  }
</script>

var映射;
函数初始化(){
变量映射选项={
中心:新google.maps.LatLng(28.6377.21),
缩放:8,
disableDefaultUI:false,
mapTypeId:google.maps.mapTypeId.ROADMAP
};
map=new google.maps.map(document.getElementById(“地图画布”),
地图选项);
}
//google.maps.event.addDomListener(窗口“加载”,初始化);
函数getFillingDetails(){
var vehicleId=$('#selectVehicle选项:selected').val();
$.getJSON('getFillingDetails.php',{id:vehicleId},函数(数据){
var-lat=[];
var-lon=[];
var价格=[];
$。每个(数据、函数(键、值){
横向推力(值、纬度);
长推力(值、经度);
价格.推送(价值.价格);
});
});
var mylatng=newgoogle.maps.LatLng(23.72,77.10);
var marker=new google.maps.marker({
位置:新google.maps.LatLng(23.72,72.100),
地图:地图,
});
}
我觉得一切都很好。在
body
标记的
onload
之后调用
initialize()
函数。 当我点击一个按钮时,
getFillingDetails()
函数被调用。
但我仍然没有成功。

您在以下位置出现语法错误:

var marker = new google.maps.Marker({
    position: new google.maps.LatLng(23.72, 72.100),
    map: map, <--- get rid of this comma
});
var marker=new google.maps.marker({
位置:新google.maps.LatLng(23.72,72.100),

map:map,您在以下位置出现语法错误:

var marker = new google.maps.Marker({
    position: new google.maps.LatLng(23.72, 72.100),
    map: map, <--- get rid of this comma
});
var marker=new google.maps.marker({
位置:新google.maps.LatLng(23.72,72.100),
地图:地图,
资料来源:


来源:

删除逗号(,)这里映射:映射,。这将起作用:)它仍然不起作用抱歉那些愚蠢的东西..它起作用了。愚蠢的我..删除逗号(,)这里映射:映射,。这将起作用:)它仍然不起作用抱歉那些愚蠢的东西..它起作用了。愚蠢的我..它仍然不起作用。我需要调用
marker.setMap(映射)
在标记代码之后。?它仍然不工作。我是否需要在标记代码之后调用
marker.setMap(map);