googlemaps / google-maps-ios-utils

Google Maps SDK for iOS Utility Library
https://developers.google.com/maps/documentation/ios-sdk/utility/
Apache License 2.0
716 stars 408 forks source link

HeatMap not visible when it is zoomed in. #371

Open gurjnderSingh opened 3 years ago

gurjnderSingh commented 3 years ago

When I do zoom in, HeatMap is visible. As soon I started zoon in I am unable to see the color of the Heat Map.

I am using the same code private var gradientColors = [UIColor.green, UIColor.red] private var gradientStartPoints = [0.2, 1.0] as [NSNumber]

  mapView.delegate = self
  heatmapLayer = GMUHeatmapTileLayer()
  heatmapLayer.radius = 100
  heatmapLayer.opacity = 0.7
  heatmapLayer.gradient = GMUGradient(colors: gradientColors,
                                        startPoints: gradientStartPoints,
                                        colorMapSize: 156)

My code is same as you provided on Google developer site Please let me know if anything is misssing Thanks!

gurjnderSingh commented 3 years ago

Before ZoomIn CropUploadTeek

After Zoom In CropWrong

arriolac commented 3 years ago

This is perhaps due to the radius size you have set. Based on our docs, the value is recommended to be between 10 and 50. See: https://developers.google.com/maps/documentation/ios-sdk/utility/heatmap#customize-the-heatmap

gurjnderSingh commented 3 years ago

@arriolac Thanks! for your reply. But radius has no effect on this. I have tried all values from 10-60 for radius, for opacity value 1, and colorMapSize value 256. All these have no effect when I do zoom in. The result is the same as the above ss. Even I tried in the sample GitHub code the result is the same. In Android, the same is working fine i.e I have to do the same.

gurjnderSingh commented 3 years ago

@arriolac Please help to find the solution.

james-innes commented 2 years ago

Set maxIntensity: 3, as an option of the HeatmapLayer. Before setting this there was just a blur. This map has over ~14k points.

Screenshot 2022-06-13 at 12 51 31 pm

Or where there is a high density of points replace them with one point with a greater weight for performance if you don't require the pin point detail.

hanandika commented 1 year ago

Try this


private var gradientColors = [UIColor.green, UIColor.red]
private var gradientStartPoints = [0.05, 0.5] as [NSNumber]
.
.
.
// Set heatmap options.
heatmapLayer = GMUHeatmapTileLayer()
heatmapLayer.radius = 100
heatmapLayer.opacity = 1.0
heatmapLayer.gradient = GMUGradient(colors: gradientColors,
                                  startPoints: gradientStartPoints,
                                  colorMapSize: 256)
heatmapLayer.maximumZoomIntensity = 17
heatmapLayer.minimumZoomIntensity = 10

after that add your lat lng list to weightData

// Add the latlngs to the heatmap layer.
heatmapLayer.weightedData = list

Simulator Screen Shot - iPhone 14 Pro - 2022-12-01 at 13 18 12 Simulator Screen Shot - iPhone 14 Pro - 2022-12-01 at 13 19 42

Rob-Biemans commented 1 year ago

Set the colorMapSize to 16000 @gurjnderSingh