无限滚动的传单地图-Ajax回调

时间:2018-08-08 13:47:50

标签: javascript ajax wordpress leaflet infinite-scroll

leaflet.js的新功能,并在无限滚动页面上进行ajaxcomplete调用后尝试加载地图,当前地图显示在第一页:

<div id="mapid-<?php the_ID(); ?>"></div>
<?php 
      $location = get_field('map');
      if( !empty($location) ):
        $lat = @$location['lat'];
        $lng = @$location['lng'];
      endif;

      if($lat!="" and $lng !="") { ?>
<script>
    var mbUrl = 'https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw';
    var grayscale   = L.tileLayer(mbUrl, {id: 'mapbox.light'})
    var mymap = L.map('mapid-<?php the_ID(); ?>', {
                center: [<?php echo $lat; ?>, <?php echo $lng; ?>],
                zoom: 13,
                layers: [grayscale],
                zoomControl: false,
                attributionControl: false,
                dragging: false,
                scrollWheelZoom: false
            });
    var myIcon = L.icon({
                iconUrl: 'https://cicom.staging.wpengine.com/wp-content/themes/smart-mag/images/ci-marker.png'});
    L.marker([<?php echo $lat; ?>, <?php echo $lng; ?>],{icon: myIcon}).addTo(mymap);
</script> 
<?php }  ?>

但是当我到达页面底部并且使用无限滚动加载第二个页面时,我只获得了带有mapid的div,但是没有加载带有传单代码的脚本。有什么建议么?谢谢!

0 个答案:

没有答案