Example usage for com.google.gwt.maps.client.visualizationlib HeatMapLayer setData

List of usage examples for com.google.gwt.maps.client.visualizationlib HeatMapLayer setData

Introduction

In this page you can find the example usage for com.google.gwt.maps.client.visualizationlib HeatMapLayer setData.

Prototype

public final native void setData(MVCArray<LatLng> dataPoints);

Source Link

Document

Sets the data points to be displayed by this heatmap.
NOTE: To clear the map points, set equal to an empty array.

Usage

From source file:com.google.gwt.maps.testing.client.maps.HeatMapLayerWidget.java

License:Apache License

private void drawMap() {
    // zoom out for the clouds
    LatLng center = LatLng.newInstance(40.74, -73.94);
    MapOptions opts = MapOptions.newInstance();
    opts.setZoom(11);/*from  w  w  w.ja  va2 s .c om*/
    opts.setCenter(center);
    opts.setMapTypeId(MapTypeId.TERRAIN);

    mapWidget = new MapWidget(opts);
    pWidget.add(mapWidget);
    mapWidget.setSize("750px", "500px");

    // show transit layer
    TransitLayer transitLayer = TransitLayer.newInstance();
    transitLayer.setMap(mapWidget);

    // create layer
    HeatMapLayerOptions options = HeatMapLayerOptions.newInstance();
    options.setOpacity(0.9);
    options.setRadius(5);
    options.setGradient(getSampleGradient());
    options.setMaxIntensity(3);
    options.setMap(mapWidget);

    HeatMapLayer heatMapLayer = HeatMapLayer.newInstance(options);
    // set data
    JsArray<LatLng> dataPoints = getSampleData();
    heatMapLayer.setData(dataPoints);

    // the other way to set data
    // note JS array can be set from this method, but only MVCArray from the
    // options setData() method
    // MVCArray<WeightedLocation> weightedDataPoints =
    // MVCArray.newInstance(getSampleWeightedData());
    // heatMapLayer.setDataWeighted(weightedDataPoints);
    GWT.log("Plotting " + dataPoints.length() + " points on HeatMap");
}