CartoDB / mobile-ios-samples

iOS mobile app with CARTO Mobile SDK
BSD 2-Clause "Simplified" License
30 stars 12 forks source link

Rendering points into Heatmap #11

Closed Kysiek closed 7 years ago

Kysiek commented 7 years ago

Hi,

I would like to render points using mobile sdk in my iOS app like I could render them using web builder (see picture below) screen shot 2017-06-08 at 16 20 58

Coordinate points I would like to add manually to the map and create heat map from them, that is in my iOS app I have 200 points (latitude and longitude) and add them to the map and then render like it is shown on above image.

Could you tell me whether sdk allows us to do it? If yes, could you give me some hints how to accomplish it?

Thanks, Kysiek

Nikituh commented 7 years ago

Before we continue, one question:

Kysiek commented 7 years ago

@Nikituh, thanks for your answer :) The first case, I need it to be completely independent of Carto. i.e. in my case txt file with coordinates is bundled with the app and then I would like to add these geographical points into a map.

jaakla commented 7 years ago

SDK does not do heatmaps itself, Carto Engine-based solution requires generation of heatmaps on the server. You can try to show the data as semi-transparent points with soft borders, it may give somewhat similar visual effect like heatmap. It can even more suitable, as raster-based heatmap is not always very nice with smooth zooming as you have on mobile.

Kysiek commented 7 years ago

@jaakla thanks for the answer :)

I will carry on with the points. But, could you tell me how to do it? Should I change the style of a point using instance of NTPointStyleBuilder? To set semi-transparency and soft borders can I use carto mobile sdk or should I set somehow background of a point from an image?

jaakla commented 7 years ago

Yes, NTPointStyleBuilder is the right place to set style. I would use there two settings, set image bitmap with burred edges, for example attached one. And then set color for style, which may have also alpha-channel set. This colors the white image properly. burimage.png

Kysiek commented 7 years ago

Thanks @jaakla :). I have created radial gradient circle natively as UIView than converted it to UIImage and from that created Bitmap. It looks fine, but nevertheless I would like to test another approach - namely display created map in the carto builder in the iOS app. Could you please tell me how I could to do that? In the publish section in the builder I do not see appropriate option, only these two:

screen shot 2017-06-12 at 11 49 08

From this description

screen shot 2017-06-12 at 11 47 27

I assume that share to mobile SDK option should exist, I am right?

jaakla commented 7 years ago

Our builder team is changing many internals and currently the choice is unfortunately not enabled there.

You can try an unofficial hack trough. See ...VisController samples (e.g. CountriesVisController.m, and these do exactly what you want - load map prepared in Builder. The URL for the viz.json is currently hidden, but you can see the pattern http://$USER.cartodb.com/api/v2/viz/$MAPUUID/viz.json - just replace your user and map ID to the same what you see in link/embed URL. However, be aware that this URL may stop working in future Builder versions. This way you can 'feed' your Builder map to SDK, which has built-in parser for the viz.json files.

Kysiek commented 7 years ago

I have already constructed appropriate url and it seems to work. Thanks!