Search code examples
androidgoogle-mapsheatmapgoogle-maps-api-2

Google map v2 Heatmap population


Would it be possible to use a heat map to represent/show the amount of people in the specific area using google map v2?

If not , would there be other library or API that I can use to know represent the amount of people in the area.

reference that I saw on the internet: http://googlemapsmania.blogspot.com/2014/02/population-mapping.html


Solution

  • Hey here is the example how you can use heatmap and show your max population

    Add all marker in your map then use this code.

    HeatmapTileProvider mProvider;
    TileOverlay mOverlay;
    // Add your all lat lng inside this array list and pass it to addHeatMap
    List<LatLng> list = new ArrayList<LatLng>();
    
    double puLat = 0, puLng = 0;
    
    
    
        private void createMarker() {
        double cLat, cLng;
        cLat = locationCur.getLatitude();
        cLng = locationCur.getLongitude();
    
        Marker testMarker = googleMap.addMarker(new MarkerOptions()
                .position(new LatLng(cLat, cLng)).draggable(true)
                .title("Demanding Areas").flat(false));
    
        testMarker.showInfoWindow();
    
       }
    
        private void addHeatMap() {
    
    
        mProvider = new HeatmapTileProvider.Builder().data(list).build();
        mOverlay = googleMap.addTileOverlay(new TileOverlayOptions()
                .tileProvider(mProvider));
    }
    

    Hope this will help you