Skip to content

Commit

Permalink
feat: update cluster example
Browse files Browse the repository at this point in the history
  • Loading branch information
hansemannn committed Feb 17, 2019
1 parent 24d22fc commit 389dd76
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
6 changes: 6 additions & 0 deletions Classes/TiGooglemapsViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -793,13 +793,19 @@ - (void)showAnnotations:(id)args

- (void)setClusterConfiguration:(NSDictionary<NSString *,id> *)clusterConfiguration
{
NSArray<NSNumber *> *ranges = clusterConfiguration[@"ranges"];
NSArray<NSString *> *rangeBackgrounds = clusterConfiguration[@"rangeBackgrounds"];
NSUInteger minimumClusterSize = [TiUtils intValue:clusterConfiguration[@"minimumClusterSize"] def:4];
NSUInteger maximumClusterZoom = [TiUtils intValue:clusterConfiguration[@"maximumClusterZoom"] def:20];
double animationDuration = [TiUtils doubleValue:clusterConfiguration[@"animationDuration"] def:0.5];

[self mapView].clusterRenderer.minimumClusterSize = minimumClusterSize;
[self mapView].clusterRenderer.maximumClusterZoom = maximumClusterZoom;
[self mapView].clusterRenderer.animationDuration = animationDuration;

// Set the proxy values to the old keys for background compatibility
[self replaceValue:ranges forKey:@"clusterRanges" notification:NO];
[self replaceValue:rangeBackgrounds forKey:@"clusterBackgrounds" notification:NO];
}

@end
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -658,14 +658,19 @@ You are all set! Optionally, you can also set your own cluster ranges and define
images for each cluster range in your `mapView` instance:
```js
var mapView = maps.createView({
clusterRanges: [10, 50, 100, 200, 500],
clusterBackgrounds: [
'buckets/m1.png',
'buckets/m2.png',
'buckets/m3.png',
'buckets/m4.png',
'buckets/m5.png'
],
clusterConfiguration: {
ranges: [10, 50, 100, 200, 500],
rangeBackgrounds: [
'buckets/m1.png',
'buckets/m2.png',
'buckets/m3.png',
'buckets/m4.png',
'buckets/m5.png'
],
minimumClusterSize: 4,
maximumClusterZoom: 20,
animationDuration: 0.5
},
region: {
latitude: 37.368122,
longitude: -121.913653,
Expand Down
21 changes: 13 additions & 8 deletions example/clustering.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,19 @@ var location = {
* MapView
*/
var mapView = maps.createView({
clusterRanges: [10,50,100,200,500],
clusterBackgrounds: [
'buckets/m1.png',
'buckets/m2.png',
'buckets/m3.png',
'buckets/m4.png',
'buckets/m5.png'
],
clusterConfiguration: {
ranges: [10, 50, 100, 200, 500],
rangeBackgrounds: [
'buckets/m1.png',
'buckets/m2.png',
'buckets/m3.png',
'buckets/m4.png',
'buckets/m5.png'
],
minimumClusterSize: 4,
maximumClusterZoom: 20,
animationDuration: 0.5
},
region: {
latitude: location.latitude,
longitude: location.longitude
Expand Down

0 comments on commit 389dd76

Please sign in to comment.