Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps api 3 为什么Marker Manager不';不行?_Google Maps Api 3_Javascript - Fatal编程技术网

Google maps api 3 为什么Marker Manager不';不行?

Google maps api 3 为什么Marker Manager不';不行?,google-maps-api-3,javascript,Google Maps Api 3,Javascript,我将使用MarkerManager将相邻的标记分组到一个标记中,我测试了一个示例,但它不起作用。不同的标记显示得很好,但它们在应该显示的时候并不在一起。经理工作不正常,我不明白为什么 <html> <head> <title>Test GMap - MarkerManager</title> <script src="http://maps.googleapis.com/maps/api/js?sensor=false">

我将使用MarkerManager将相邻的标记分组到一个标记中,我测试了一个示例,但它不起作用。不同的标记显示得很好,但它们在应该显示的时候并不在一起。经理工作不正常,我不明白为什么

<html>
<head>
    <title>Test GMap - MarkerManager</title>
    <script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
    <script src="http://google-maps-utility-library-v3.googlecode.com/svn/tags/markermanager/1.0/src/markermanager.js"></script>
    <script src="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/src/markerclusterer_compiled.js"></script>
</head>

<body>
    <div id="my-map" style="width:100%;height:700px"></div>
    <script>
        var maCarte = '';
        function initialisation(){
            var centreCarte = new google.maps.LatLng(47.389982, 0.688877);
            var optionsCarte = {
                        zoom: 5,
                        center: centreCarte,
                        mapTypeId: google.maps.MapTypeId.ROADMAP
                    }
            maCarte = new google.maps.Map(document.getElementById("my-map"), optionsCarte);
            // Create a new instance of the MarkerManager
            var mgr = new MarkerManager(maCarte);
            google.maps.event.addListener(mgr, 'loaded', function() {
                console.log('loaded Map');
                // Create marker array
                var markers = [];
                // Loop to create markers and adding them to the MarkerManager
                for(var i = 0; i < 50; i += 0.1) {
                    var marker = new google.maps.Marker({position: new google.maps.LatLng(47.389982 + i, 0.688877 + i)});
                    markers.push(marker);
                }
                //var markerCluster = new MarkerClusterer(map, markers);
                // Add the array to the MarkerManager
                mgr.addMarkers(markers, 8);
                // Refresh the MarkerManager to make the markers appear on the map
                mgr.refresh();
            });
        }

        google.maps.event.addDomListener(window, 'load', initialisation); 
    </script>
</body>

测试GMap-MarkerManager
var maCarte=“”;
函数初始化(){
var centrecart=new google.maps.LatLng(47.389982,0.688877);
var期权单={
缩放:5,
中心:centreCarte,,
mapTypeId:google.maps.mapTypeId.ROADMAP
}
maCarte=new google.maps.Map(document.getElementById(“我的地图”),optionScote);
//创建MarkerManager的新实例
var mgr=新的MarkerManager(maCarte);
google.maps.event.addListener(mgr,'loaded',function(){
log('loaded Map');
//创建标记数组
var标记=[];
//循环以创建标记并将其添加到MarkerManager
对于(变量i=0;i<50;i+=0.1){
var marker=new google.maps.marker({位置:new google.maps.LatLng(47.389982+i,0.688877+i)});
标记器。推(标记器);
}
//var markerCluster=新的MarkerClusterer(地图、标记);
//将数组添加到MarkerManager
经理(markers,8);
//刷新MarkerManager以使标记显示在地图上
经理刷新();
});
}
google.maps.event.AddDomainListener(窗口“加载”,初始化);

有人能帮我吗


非常感谢

您的页面适合我,但页面加载时标记不会立即可见。这是因为第34行上的缩放设置:

mgr.addMarkers(markers, 8);

如果将其设置为较低的数字(例如,4),则当进一步放大时,标记将可见。

如果您能够更准确地了解问题所在,以及迄今为止您已尝试解决的问题,则获得答案的机会将更大。这里的示例非常清楚:好的,谢谢您的回答。我的问题是,当缩放距离较远时,我希望标记以这种方式显示:您的意思是只希望标记在特定的缩放范围内显示?您可以将低缩放值和高缩放值传递给addMarkers方法:mgr.addMarkers(markers,4,6);