Skip to content
This repository has been archived by the owner on Dec 8, 2017. It is now read-only.

Heat maps #27

Closed
1ec5 opened this issue Sep 21, 2016 · 6 comments
Closed

Heat maps #27

1ec5 opened this issue Sep 21, 2016 · 6 comments

Comments

@1ec5
Copy link
Contributor

1ec5 commented Sep 21, 2016

This GL JS example and this Android SDK demo app activity claim to demonstrate “heat maps”, but in reality they’re hot spot maps. The “heat” only represents frequency, but not, say, a magnitude property in the GL JS example. The overlaid shapes can be blurred circles but not amorphous shapes, and the heat comes apart as you zoom in rather than spreading out.

Some of the requests we’ve gotten for heat maps (such as mapbox/mapbox-gl-native#3420, mapbox/mapbox-gl-native#6304) have turned out to be for actual heat maps. In the Google Maps JavaScript API, HeatmapLayer can work with WeightedLocations for this effect. The Google Maps SDK for Android supports heat maps as well using HeatmapTileProvider and WeightedLatLng. On iOS/macOS, there are a number of libraries based on MapKit (example) that implement heat maps using a custom-rendered MKOverlayView or the more modern MKOverlayRenderer.

The Android and iOS SDKs support something along the lines of these MapKit-based libraries, via an unsupported, undocumented OpenGL style layer API. But we should have a straightforward, officially supported solution for heat maps. As far as I can tell, we may need a new layer type that clusters nearby points of similar intensity into amorphous shapes (rather than collapsing them down into a single point). Please chime in if you think it’s doable with the existing layer types, though.

/cc @mourner @lucaswoj @danswick @noemiwalzebuck @johndpope

@lucaswoj
Copy link

Prior art of which I'm aware:

@johndpope
Copy link

johndpope commented Dec 10, 2016

https://developer.skobbler.com/
also noteworthy -

screen shot 2016-12-09 at 21 41 14

@johndpope
Copy link

johndpope commented Dec 17, 2016

I did it using the raster tile overlay.
(ideally it would be done using opengl but this is ok out of the gate)
img_8306
(this involved hacking the http_file_source.mm and would also involve protocol swizzling in order to override the control flow outside of sdk)

 NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration defaultSessionConfiguration];
        sessionConfig.protocolClasses = @[NetSandbox.class];

inside the http_file_source.mm to overide the

NetSandbox.h
https://gist.github.com/johndpope/ebcb7c870cb09fd0cbf9b822f3f677a6

https://gist.github.com/johndpope/fc9749391faad76ee6b94d2ea7a237b6

IMPORTANT
At the heart of this - I need the mapbox SDK to surface a way to provide a raster datasource for local data (not by disk location) / but by a delegate / callback like MKTileOverlay methods.
(or document the way to do this - as it's not entirely obvious)

eg.
GridTileOverlay
-(void)loadTileAtPath:(MKTileOverlayPath)path result:(void (^)(NSData *, NSError *))result {
UIImage *image = [GridTileOverlay imageForTileX:x y:y z:z];
NSData *tileData = UIImagePNGRepresentation(img);
result(tileData,nil);
}

@1ec5
Copy link
Contributor Author

1ec5 commented Dec 17, 2016

At the heart of this - I need the mapbox SDK to surface a way to provide a raster datasource for local data (not by disk location) / but by a delegate / callback like MKTileOverlay methods.
(or document the way to do this - as it's not entirely obvious)

There isn’t currently a way to do this for raster content, other than to stand up a local server and point an MGLRasterSource at it. mapbox/mapbox-gl-native#7471 would introduce an API very similar to -[MKTileOverlay loadTileAtPath:result:].

@lucaswoj
Copy link

Migrated to mapbox/mapbox-gl-js#3994

@1ec5
Copy link
Contributor Author

1ec5 commented May 25, 2017

The discussion moved to mapbox/mapbox-gl-js#4756, since we realized TINs wouldn’t help us implement heat maps.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants