Google Map API v3不会改变鼠标悬停的位置

时间:2012-12-18 12:37:01

标签: google-api

<script type="text/javascript">

    var markers = [ 
     <?php 
     $siteCount = count($content);
     $aaa=0;
     foreach($content as $con){
     $aaa++;
     $address = $con['Country'].','.$con['State_Province_Name'].','.$con['address'];
     $arr = $obj->getCoordinates($address);
     ?>
    ['<?php echo $con['name'];?>', <?php echo $arr['lat'];?>, <?php echo $arr['long'];?>]<?php if($siteCount==$aaa){ echo "\n";}else{ echo ",";  echo "\n";}?>
    <?php } ?>
];
</script>



<script>
function initializeMaps() {

    var latlng = new google.maps.LatLng(<?php if($arrval==''){echo "43.1291";} else{echo $arr['lat'];}?>, <?php if($arrval==''){echo "-77.6717";} else{echo $arr['long'];}?>);
    var myOptions = {
        zoom: 17,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.SATELLITE,
        mapTypeControl: true
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);

    var infowindow = new google.maps.InfoWindow(), marker, i;
    for (i = 0; i < markers.length; i++) {  
        marker = new google.maps.Marker({
            position: new google.maps.LatLng(markers[i][1], markers[i][2]),
            map: map
        });
        google.maps.event.addListener(marker, 'click', (function(marker, i) {
            return function() {
                infowindow.setContent(markers[i][0]);
                infowindow.open(map, marker);
            }
        })(marker, i));

         google.maps.event.addListener(marker, 'mouseover', (function(marker, i) {
            return function() {
                infowindow.setContent(markers[i][0]);
                infowindow.open(map, marker);
                marker.setAnimation(google.maps.Animation.BOUNCE);
            }
        })(marker, i));


         google.maps.event.addListener(marker, 'mouseout', (function(marker, i) {
            return function() {
                infowindow.setContent();
                infowindow.open();

    setTimeout(function(){ marker.setAnimation(null); }, 0);
            }
        })(marker, i));



    }
}



    </script>

这是我的代码

我想将鼠标悬停在页面鼠标上的位置改为仅适用于地图上的作品

这里我从页面

调用该函数
<a  href="javascript:google.maps.event.trigger(markers['<?php echo $content1['name'];?>'],'mouseover'); "><?php echo $content1['name'];?></a>

但这不起作用

0 个答案:

没有答案