-1
我遇到問題。這是我的地圖代碼。它運作良好。它動態地顯示地圖圖標。現在我想添加地圖圖標懸停名稱動態。我怎樣才能做到這一點?地圖圖標名稱動態添加
<script>
var infowindows = [];
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 7,
center: new google.maps.LatLng(<?php echo $flag[0]->lat; ?>, <?php echo $flag[0]->lang; ?>),
mapTypeId: 'roadmap'
});
var icons = {
parking: {
icon: '<?php echo get_template_directory_uri(); ?>/img/icon332.png'
}
};
var features = [
<?php
foreach($map as $map)
{
?>
{
position: new google.maps.LatLng(<?php echo $map->lat;?>, <?php echo $map->lang;?>),
type: 'parking'
},
<?php
}
?>
];
features.forEach(function(feature) {
var marker = new google.maps.Marker({
position: feature.position,
//position: currentLatLng,
icon: icons[feature.type].icon,
map: map
});
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDr-oU870bxiB7TJcrlfAtN9HjEvZzjdGI&callback=initMap"></script>