Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.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 Marker event.listener迭代问题,Laravel_Javascript_Php_Laravel - Fatal编程技术网

Javascript Marker event.listener迭代问题,Laravel

Javascript Marker event.listener迭代问题,Laravel,javascript,php,laravel,Javascript,Php,Laravel,我在这里要做的。当我按记号笔的时候。它会把我送到那个id的页面。它将我发送到id页面。但我点击哪个标记并不重要,我总是去同一个id的页面。侦听器工作不正常。。。我想 这是完整的地图: var estates = <?php echo json_encode($estates);?>; function initMap() { var options = { zoom : 6, cen

我在这里要做的。当我按记号笔的时候。它会把我送到那个id的页面。它将我发送到id页面。但我点击哪个标记并不重要,我总是去同一个id的页面。侦听器工作不正常。。。我想

这是完整的地图:

  var estates = <?php echo json_encode($estates);?>;

  function initMap()
  {
      var options =
          {
              zoom : 6,
              center : {lat:34.652500, lng:135.506302}
          };

      var map = new google.maps.Map(document.getElementById('map'), options);
      @foreach ($estates as $est)
      var marker = new google.maps.Marker({
                map: map,
                icon: 'imgs/marker.png',
                url: "/pages/{{$est->id}}",
                label: {
                    text: estates.data[0].price.substring(0, 5),
                    color: "#fff",
                },
                position: {
                    lat: {{$est->lat}},
                    lng: {{$est->lng}}
                }
            });

           google.maps.event.addListener(marker, 'click', function () {
           window.location.href = marker.url;
         });
      @endforeach
  }
var地产=;
函数initMap()
{
var期权=
{
缩放:6,
中心:{纬度:34.652500,液化天然气:135.506302}
};
var map=new google.maps.map(document.getElementById('map'),options);
@foreach($est的不动产)
var marker=new google.maps.marker({
地图:地图,
图标:“imgs/marker.png”,
url:“/pages/{{$est->id}}”,
标签:{
文本:estates.data[0].price.substring(0,5),
颜色:“fff”,
},
职位:{
纬度:{{$est->lat},
液化天然气:{{$est->lng}
}
});
google.maps.event.addListener(标记,'click',函数(){
window.location.href=marker.url;
});
@endforeach
}

有没有办法解决这个问题

似乎是
window.location.href=marker.url缺少
[i]
标记

请尝试:

google.maps.event.addListener(marker, 'click', function () {
    window.location.href = this.url;
});

不,这不是问题所在。我也尝试添加它,
marker[I].url
无效果。。。