0

所以我有一张我正在处理的地图,像这样动态加载:

foreach( $myposts as $post ) :  setup_postdata($post); ?>                                

    var marker<?php echo $count; ?> = new google.maps.Marker({ position: new google.maps.LatLng<?php the_field('longlat'); ?>, map: map, title:"<?php the_title(); ?>, <?php the_field('address'); ?>", icon:image });

    google.maps.event.addListener(marker<?php echo $count; ?>, 'click', function()
    {

        alert('you clicked: <?php the_title(); ?> - <?php the_field('address'); ?>');

    });

    <?php $count++ ?>

    <?php endforeach; ?>

我想要它做的是优雅地加载带有标题和地址的标记弹出窗口......这是来自php的这两个值:

<?php the_title(); ?> - <?php the_field('address'); ?>

目前它会这样做,但在警报中......

那么如何设置它以使其出现在标记上方的弹出窗口中?

感谢您的帮助!

4

1 回答 1

1

我建议您在以下位置查看infoWindow课程和相关文档:https ://developers.google.com/maps/documentation/javascript/reference#InfoWindow

也有相关的代码示例: https ://developers.google.com/maps/documentation/javascript/demogallery

在您有警报代码的地方,您可以输入以下内容:

var infowindow = new google.maps.InfoWindow();
infowindow.setContent('Whatever you want in the popup');
infowindow.open(map, this);
于 2012-04-24T04:18:37.330 回答