Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/427.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
Javascript 如何在angularjs中向google地图添加群集标记_Javascript_Angularjs_Google Maps - Fatal编程技术网

Javascript 如何在angularjs中向google地图添加群集标记

Javascript 如何在angularjs中向google地图添加群集标记,javascript,angularjs,google-maps,Javascript,Angularjs,Google Maps,我正在尝试在angularjs中向google地图添加集群标记 我已经包括了js文件()和图像() 但是,集群仍然没有出现 这是我的代码: html: <section id="GoogleMaps" ng-controller="MapsController"> <div class="container"> <div> <div id="map_canvas"></div> </div>

我正在尝试在angularjs中向google地图添加集群标记

我已经包括了js文件()和图像()

但是,集群仍然没有出现

这是我的代码:

  • html:

    <section id="GoogleMaps" ng-controller="MapsController">
    <div class="container">
        <div>
            <div id="map_canvas"></div>
        </div>
    </div>
    </section>
    
  • 脚本:

    addTag('script', { src: 'http://maps.googleapis.com/maps/api/js' }, sync);
    addTag('script', { src: 'assets/js/markerclusterer.js' }, sync);
    
  • 你知道怎么加吗


    谢谢。

    按以下方式初始化Marker群集

    $scope.initMap = function (data) {
     var mapOptions = {
         zoom: 7,
         center: new google.maps.LatLng(48.209500, 16.370691),
         mapTypeId: google.maps.MapTypeId.ROADMAP
     };
     var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
     var markerArray = [];
    
    
     data.forEach(function (item) {
         var marker = new google.maps.Marker({
             position: new google.maps.LatLng(item.LAT, item.LON),
             animation: google.maps.Animation.Bounce,
             map: map
         });
    
         markerArray.push(marker);
     });
    
    var options = {
        imagePath: 'images/m'
    };
    
    var markerCluster = new MarkerClusterer(map, markerArray, options);
    };
    
    当您在forEach循环中初始化它时,它将创建它的新对象

    $scope.initMap = function (data) {
     var mapOptions = {
         zoom: 7,
         center: new google.maps.LatLng(48.209500, 16.370691),
         mapTypeId: google.maps.MapTypeId.ROADMAP
     };
     var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
     var markerArray = [];
    
    
     data.forEach(function (item) {
         var marker = new google.maps.Marker({
             position: new google.maps.LatLng(item.LAT, item.LON),
             animation: google.maps.Animation.Bounce,
             map: map
         });
    
         markerArray.push(marker);
     });
    
    var options = {
        imagePath: 'images/m'
    };
    
    var markerCluster = new MarkerClusterer(map, markerArray, options);
    };