标记-event.listener迭代问题,Laravel

我想在这里做什么.当我按下标记时.它应该将我发送到该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
  }

解决这个问题的主意吗?

解决方法:

请试试:

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

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...