Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.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 在google地图中显示簇中标记的数量_Javascript_Angularjs_Google Maps_Google Maps Api 3_Angular Google Maps - Fatal编程技术网

Javascript 在google地图中显示簇中标记的数量

Javascript 在google地图中显示簇中标记的数量,javascript,angularjs,google-maps,google-maps-api-3,angular-google-maps,Javascript,Angularjs,Google Maps,Google Maps Api 3,Angular Google Maps,我是AngularJS的新手,目前正在与google maps合作 我已经看过了文档,但我想做的就是 显示群集中的数字标记 而且,单击集群后,将显示一个弹出的工具文本。 api并未广泛涵盖这一点。 我想要实现的例子就在这里 下面是我目前的代码: HTML指令 <div ng-controller="MapsController"> <ui-gmap-google-map center="map.center" zoom="map.zoom" draggable="true"

我是AngularJS的新手,目前正在与google maps合作

我已经看过了文档,但我想做的就是 显示群集中的数字标记

而且,单击集群后,将显示一个弹出的工具文本。 api并未广泛涵盖这一点。 我想要实现的例子就在这里

下面是我目前的代码:

HTML指令

<div ng-controller="MapsController">
<ui-gmap-google-map center="map.center" zoom="map.zoom" draggable="true" options="options" bounds="map.bounds">
<ui-gmap-markers doCluster="true" clusterOptions="clusterOptions" models="puMarkers" coords="'self'" icon="'icon'">
</ui-gmap-markers>
</ui-gmap-google-map>

我终于明白了。集群中的标记数量已经存在,只是因为标记图标也是黑色的,所以它是黑色字体而不是隐藏的颜色。 单击标记时显示弹出窗口也已可用
在文档中。

不确定您在哪里遇到问题。地图上有你定义的标记吗?
controllers.controller('MapsController', function($scope,mapService) {
var locationArray ;
$scope.map = {
    center: {
        latitude: 8.69128,
        longitude: 8.5208073
    },
    zoom: 6,
    bounds: {}
};
$scope.options = {
    scrollwheel: false
};

$scope.clusterOptions = {
    gridSize: 60,
    ignoreHidden: true,
    minimumClusterSize: 5,
    imageExtension: 'png',
    imagePath: 'assets/img/cluster',
    imageSizes: [72] };

var createRandomMarker = function(i, bounds, idKey,point) {
    var ret = {
        latitude: point.g,
        longitude: point.f,
        title: 'm' + i,
        icon: 'assets/img/marker.png',
        options: { title: point.t }
    };
    ret[idKey] = i;
    return ret;
};

$scope.puMarkers = [];
// Get the bounds from the map once it's loaded
$scope.$watch(function() {
    return $scope.map.bounds;
}, function(nv, ov) {
    // Only need to regenerate once
    if (!ov.southwest && nv.southwest) {
        var markers = [];

        /* Load Markers from Rest Services*/
        var promise = mapService.getPollingUnits(1);
        promise.success(function(retData,status,headers,config) {
            if (retData.error == false) {
                var i = 1 ;
                locationArray = retData.events;
                locationArray.forEach(function(item){
                    markers.push(createRandomMarker( i, $scope.map.bounds, "id", item ));
                    i++;
                });
            }
        });
        $scope.puMarkers = markers;
    }
}, true);
});