public void addHeatMap(List<GridPoint> gridPointList) { clearMap(); List<LatLng> list = new ArrayList<LatLng>(); LatLngBounds.Builder builder = new LatLngBounds.Builder(); LatLng latLng = null; for (GridPoint gridPoint : gridPointList) { latLng = new LatLng( gridPoint.getLocation().getLatitude().doubleValue(), gridPoint.getLocation().getLongitude().doubleValue()); list.add(latLng); builder.include(latLng); } if (list.size() < 1) { return; } mProvider = new HeatmapTileProvider.Builder().data(list).build(); mOverlay = googleMap.addTileOverlay(new TileOverlayOptions().tileProvider(mProvider)); if (gridPointList.size() > 1) { LatLngBounds bounds = builder.build(); CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, 0); googleMap.animateCamera(cu); } else if (gridPointList.size() > 0) { CameraPosition cameraPosition = new CameraPosition.Builder().target(latLng).zoom(zoomLevel).bearing(0).tilt(45).build(); googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); } markersDisplayed = false; heatmapDisplayed = true; clusterDisplayed = false; }
@Override public void updateMapLayer() { MapType mapType = Controller.getInstance().getPreferencesManager().getMapType(); if (mapType == currentMapType) return; currentMapType = mapType; if (customTileOverlay != null) customTileOverlay.remove(); customTileOverlay = null; switch (mapType) { case GoogleNormal: googleMap.setMapType(MAP_TYPE_NORMAL); return; case GoogleSatellite: googleMap.setMapType(MAP_TYPE_SATELLITE); return; case GoogleTerrain: googleMap.setMapType(MAP_TYPE_TERRAIN); return; case GoogleHybrid: googleMap.setMapType(MAP_TYPE_HYBRID); return; } googleMap.setMapType(MAP_TYPE_NONE); // Don't display any google layer UrlTileProvider provider = getTileProvider(mapType); if (provider != null) { customTileOverlay = googleMap.addTileOverlay(new TileOverlayOptions().tileProvider(provider)); customTileOverlay.setZIndex(-100); } }