1
<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>

しかし、これは機能しません

4

0 に答える 0