谷歌地图infoWindows

时间:2014-03-13 08:48:14

标签: jquery google-maps

我有一个问题,我希望当我点击一个超链接时它会关注我并向我展示这个InfoWindow。不幸的是,我尝试了两天没有成功。

<script>
var villes = [
                {/literal}{data_gmap}{literal}
            ];
        function initialize() {
        var mapOptions = {
        zoom: 12,
                center: new google.maps.LatLng(47.90414530044006, 1.9050121307373047),
                mapTypeId: google.maps.MapTypeId.ROADMAP,
                scrollwheel: true
        }
        var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
                setMarkers(map, villes);
        }
function centerPoi(longitude, latitude){
var mapOptions = {
zoom:17,
        center: new google.maps.LatLng(longitude, latitude),
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        scrollwheel: true
}
var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
        setMarkers(map, villes);
}
function setMarkers(map, locations) {
var image = 'uploads/images/logomaps.png';
        for (var i = 0; i < locations.length; i++) {
var villes = locations[i];
        var myLatLng = new google.maps.LatLng(villes[1], villes[2]);
        var infoWindow = new google.maps.InfoWindow();
        var marker = new google.maps.Marker({
        position: myLatLng,
                map: map,
                animation: google.maps.Animation.DROP,
                icon: image
        });
        (function (i) {
        google.maps.event.addListener(marker, "click", function() {
        var villes = locations[i];
        infoWindow.close();
        infoWindow.setContent(
        "<div id='boxcontent' style='font-family:Calibri'><strong >"+ villes[0] +" €</strong><br /><span style='font-size:12px;color:#333'>"+ villes[3] +"<br/>"+ villes[4] +"<br/>"+ villes [5] + "</span></div>");
        infoWindow.open(map, this);
        });
        })(i);

}
}
</script>

我的超链接:

 <a href="#" onClick="centerPoi(\''.$data[$i]['latitude'].'\',\''.$data[$i]['longitude'].'\'); google.maps.event.addListener(marker'.$i.', \'click\');" class="hyperlink'.$i.'">'.$data[$i]['nom'].'</a>

如果有人有想法或可以指导我?

谢谢!

0 个答案:

没有答案