Click or drag to resize

Telogis.GeoBase.MapLayers.ClusterLayer

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release

MapLayers.ClusterLayer inherits from MapLayers.ObjectLayer.

Creates a layer to contain multiple MapLayers.ImageObject instances, which displays cluster icons for clusters obtained from a given datasource.

Constructor
NameDescription
MapLayers.ClusterLayer(config)

Arguments

  • config (Object) - Configuration options for the MapLayers.ClusterLayer.

    Properties
    NameTypeDescription
    preSendCallback (XMLHttpRequest request) Function

    A callback that is fired before each XMLHttpRequest is sent. It takes the request as an argument. It can be used to set a header, for example:

    JavaScript
    function addHeader(request) {
        request.setRequestHeader('HeaderName', 'value');
    }
    
    var clusterLayer = new ClusterLayer({
        usePost: true,
        preSendCallback: addHeader,
        // id, map, other options
    });

    Only applicable when usePost is set to true.

    Arguments
    • request (XMLHttpRequest) - The POST request which is being sent, after .open() has been called.

    urlString

    The URL to use when fetching cluster information.

    usePostBoolean

    Whether to use HTTP POST request method instead of GET method.

    Defaults to false.
Functions
NameDescription
createCluster (Cluster cluster)

Creates a ImageObject for a given cluster. This may be overridden to enable advanced ImageObject features such as balloons.

JavaScript
// Create a new ClusterLayer
var clusterlayer = new ClusterLayer({
    id: 'main_map_clusters',
    map: map,
    url: 'tutorial.clustering.ashx'
});

// Override createCluster to add balloons displaying cluster count
clusterlayer.createCluster = function(cluster) {
    return new ImageObject({
        layer : this,
        src : this.getClusterImageUrl(cluster),
        location : cluster.centerOfGravityLatLon,
        anchorPoint : this.getClusterImageAnchor(cluster),
        balloonConfig : {    content : "Cluster Count: " + cluster.count}
    });
};
Arguments
  • cluster (Cluster) - The cluster.

getClusterImageAnchor (Cluster cluster)

Gets the image anchor for a given cluster.

Arguments
  • cluster (Cluster) - The cluster to get an image anchor for.

getClusterImageUrl (Cluster cluster)

Gets the image URL for a given cluster.

Arguments
  • cluster (Cluster) - The cluster to get a URL for.

onClusterCreated (Cluster cluster, AbstractObject object)

Called when a cluster is created. Override this to bind events.

JavaScript
// Create a new ClusterLayer
var clusterlayer = new ClusterLayer({
    id: 'main_map_clusters',
    map: map,
    url: 'tutorial.clustering.ashx'
});

// Override onClusterCreated to add a mouse event. Clicking on a cluster
// will zoom/center the map to display the area represented by that cluster.
clusterlayer.onClusterCreated = function(cluster, object) {
    object.RightClick.append(function(e) {
        map.zoomTo(cluster.boundingBox);
    });
};
Arguments
  • cluster (Cluster) - The newly created cluster.

  • object (AbstractObject) - The associated AbstractObject.

onClustersReturned (ClusterSet result)

Called each time a ClusterSet is returned from the server while updating a ClusterLayer.

Arguments
  • result (ClusterSet) - The clusters returned from the server

refresh ()

Refresh the cluster layer(s) immediately.

setUrl (String url)

Set the cluster layer url.

Arguments
  • url (String) - The cluster url to use. If no url is supplied in string format, no clusters will be rendered on the map.

Properties
NameTypeDescription
ErrorEventHandler

Triggered when ClusterLayer receives cluster error from GeoStream

RequestEventHandler

Triggered when ClusterLayer sends a request for clusters to GeoStream

ResponseEventHandler

Triggered when ClusterLayer receives clusters from GeoStream

updateDelayNumber

Amount of time in MS to delay refreshing clusters.