小编use*_*303的帖子

打开每个多边形谷歌地图V3的InfoWindow

希望有人可以帮我解决这个问题.我正在尝试为用户创建的每个多边形单击打开信息窗口.我使用相同的代码作为标记,并且运行良好,但我无法使其适用于每个多边形.

有关如何解决这个问题的任何想法?

谢谢.

var contentString = '<div id="content">'+
    '<div id="siteNotice">'+
    '</div>'+
    '<h2>Test</h2>'+
    '</div>';

var infowindow = new google.maps.InfoWindow({
    content: contentString
});
Run Code Online (Sandbox Code Playgroud)

//显示区域

<?php foreach ($field->result() as $f):?>

// Create an array with the coordanates of each area

var field<?=$f->id?>Coords = [
    <?php $latlng=$this->resources_data->field_latlng($f->id);?>
    <?php foreach ($latlng->result() as $point):?>
    new google.maps.LatLng(<?=$point->lat?>, <?=$point->lng?>),
    <?php endforeach;?>
];

// Create a polygon with the points of the area

var area<?=$f->id?>=new google.maps.Polygon({
    paths: area<?=$f->id?>Coords,
    strokeColor: '#FF0000',
    strokeOpacity: 0.8,
    strokeWeight: 2,
    fillColor: '#FF0000',
    fillOpacity: 0.35
}); …
Run Code Online (Sandbox Code Playgroud)

polygon infowindow google-maps-api-3

12
推荐指数
1
解决办法
2万
查看次数

标签 统计

google-maps-api-3 ×1

infowindow ×1

polygon ×1