adc06 adc06 - 6 months ago 85
AngularJS Question

Any documentation on angular google maps clustering options?

Hi I am using the Angular Google Maps library available here https://github.com/nlaplante/angular-google-maps. it seems pretty powerful but it lacks exhaustive documentation... I am trying to cluster my markers but I can't find a working example of how to do it. Did anyone manage to do it ?

Answer

The question is a bit old, but maybe this can be useful for someone with the same issue.

Here is a simple example from the code I used:

On my controller, I generate a markers array with this structure:

 var markers = new Array();

    for(var i = 0; i < someData.length; i++ ){

        var newMarker = {
            id: parseInt(i),
            latitude: parseFloat(someData[i].latitude),
            longitude: parseFloat(someData[i].longitude),
            showWindow: false,
            title: "Marker"+i,
        }

        newMarker.onClicked = function () {
            alert(newMarker.id);
        }

        markers.push(newMarker);
    }

    $scope.markers = markers;

Then on the view:

<google-map center="map.center" draggable="true" options=map.options zoom="map.zoom">

        <markers models="markers" coords="'self'" doCluster=true click="'onClicked'">
        </markers>

    </google-map>
Comments