TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Apr 2015 |
Maintained by Bryan Oltman.
A heatmap for iOS, implemented as an MKOverlay
to provide seamless integration with MapKit.
This project is based on https://github.com/ryanolsonk/HeatMapDemo. It has been updated to improve performance and add a "diff" mode. https://github.com/gpolak/LFHeatMap was also referenced.
This mode is a standard heatmap and should produce the same results as the original HeatMapDemo
project, but more quickly.
This mode compares two sets of data to visualize which areas have "heated up" and which have "cooled down". Increased activity is shown with warm colors, decreased activity is shown with cool colors.
The easiest way to get DTMHeatmap
is via Cocoapods
pod 'DTMHeatmap'
Using DTMHeatmap
is relatively straightforward. After installing using the instructions above:
DTMHeatmap
MKMapPoint
(wrapped in NSValue
using [NSValue value:&point withObjCType:@encode(MKMapPoint)]
) to weightsIn the simplest form, the code looks something like this:
- (void)viewDidLoad
{
self.mapView.delegate = self;
// Create DTMHeatmap
self.heatmap = [DTMHeatmap new];
[self.heatmap setData:myData];
[self.mapView addOverlay:self.heatmap];
// or...
// Create DTMDiffHeatmap
self.diffHeatmap = [DTMDiffHeatmap new];
[self.diffHeatmap setBeforeData:beforeData
afterData:afterData];
[self.mapView addOverlay:self.diffHeatmap];
}
- (MKOverlayRenderer *)mapView:(MKMapView *)mapView
rendererForOverlay:(id<MKOverlay>)overlay
{
return [[DTMHeatmapRenderer alloc] initWithOverlay:overlay];
}
As you can see, the only difference between the stanard heatmap API and that of the diff heatmap is that the diff heatmap requires two sets of data – before and after.
A sample project (DTMHeatmapExample
) has been provided to demonstrate basic usage. There are currently four visualization options: