• Stars
    star
    195
  • Rank 199,374 (Top 4 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 12 years ago
  • Updated about 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

REMarkerClusterer creates and manages per-zoom-level clusters for large amounts of markers.

REMarkerClusterer

###REMarkerClusterer creates and manages per-zoom-level clusters for large amounts of markers.

As seen in Pinsnap iPhone app. REMarkerClusterer was inspired by the Apple Photos app on the iPhone, REMarkerClusterer mimics it's behaviour providing animations for grouping and ungrouping clusters.

REMarkerClusterer Screenshot

How it works

The REMarkerClusterer will group markers into clusters according to their distance from a cluster's center. When a marker is added, the marker cluster will find a position in all the clusters, and if it fails to find one, it will create a new cluster with the marker. The number of markers in a cluster will be displayed on the cluster marker. When the map viewport changes, REMarkerClusterer will destroy the clusters in the viewport and regroup them into new clusters.

Requirements

  • Xcode 4.6 or higher
  • Apple LLVM compiler
  • iOS 5.0 or higher
  • ARC (if you want to use in a project without ARC just add the flag -fobjc-arc to the files in the Build Phases tab of your project)

Demo

Build and run the REMarkerClustererExample project in Xcode to see REMarkerClusterer in action.

Installation

CocoaPods

The recommended approach for installating REMarkerClusterer is via the CocoaPods package manager, as it provides flexible dependency management and dead simple installation. For best results, it is recommended that you install via CocoaPods >= 0.27.0 using Git >= 1.8.0 installed via Homebrew.

Install CocoaPods if not already available:

$ [sudo] gem install cocoapods
$ pod setup

Change to the directory of your Xcode project:

$ cd /path/to/MyProject
$ touch Podfile
$ edit Podfile

Edit your Podfile and add REMarkerClusterer:

platform :ios, '6.0'
pod 'REMarkerClusterer', '~> 2.3.1'

Install into your Xcode project:

$ pod install

Open your project in Xcode from the .xcworkspace file (not the usual project file)

$ open MyProject.xcworkspace

Please note that if your installation fails, it may be because you are installing with a version of Git lower than CocoaPods is expecting. Please ensure that you are running Git >= 1.8.0 by executing git --version. You can get a full picture of the installation details by executing pod install --verbose.

Manual Install

REMarkerClusterer requires the MapKit and CoreLocation frameworks, so the first thing you'll need to do is include the frameworks into your project.

Now that the framework has been linked, all you need to do is drop files from REMarkerClusterer folder into your project, and add #include "REMarkerClusterer.h" to the top of classes that will use it.

Example Usage

// Add map view
//
self.mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
self.mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.mapView setRegion:MKCoordinateRegionMake(CLLocationCoordinate2DMake(37.786996, -97.440100), MKCoordinateSpanMake(30.03863, 30.03863)) animated:YES];
[self.view addSubview:self.mapView];

// Create clusterer, assign a map view and delegate (MKMapViewDelegate)
//
self.clusterer = [[REMarkerClusterer alloc] initWithMapView:self.mapView delegate:self];

// Set smaller grid size for an iPad
//
self.clusterer.gridSize = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ? 25 : 20;
self.clusterer.clusterTitle = @"%i items";

// Populate with sample data
//
NSDictionary *data = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Points" ofType:@"plist"]];

[data[@"Points"] enumerateObjectsUsingBlock:^(NSDictionary *dictionary, NSUInteger idx, BOOL *stop) {
    REMarker *marker = [[REMarker alloc] init];
    marker.markerId = [dictionary[@"id"] integerValue];
    marker.coordinate = CLLocationCoordinate2DMake([dictionary[@"latitude"] floatValue], [dictionary[@"longitude"] floatValue]);
    marker.title = [NSString stringWithFormat:@"One item <id: %i>", idx];
    marker.userInfo = @{ @"index": @(idx) };
    [self.clusterer addMarker:marker];
}];

// Create clusters (without animations on view load)
//
[self.clusterer clusterize:NO];

// Zoom to show all clusters/markers on the map
//
[self.clusterer zoomToAnnotationsBounds:self.clusterer.markers];

Contributors

Nicolas Yuste (@nicoyuste) Thomas Kollbach (@toto) Markus Emrich (@jaydee3)

Contact

Roman Efimov

Credits

Partially based on MarkerClusterer Javascript library by Xiaoxi Wu (http://gmaps-utility-library-dev.googlecode.com)

License

REMarkerClusterer is available under the MIT license.

Copyright © 2011-2013 Roman Efimov.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

RESideMenu

iOS 7/8 style side menu with parallax effect.
Objective-C
7,101
star
2

REFrostedViewController

iOS 7/8 style blurred view controller that appears on top of your view controller.
Objective-C
2,965
star
3

RETableViewManager

Powerful data driven content manager for UITableView.
Objective-C
2,477
star
4

REMenu

Dropdown menu inspired by Vine.
Objective-C
2,196
star
5

REComposeViewController

[DEPRECATED] Sharing composers for the rest of us.
Objective-C
649
star
6

REActivityViewController

[DEPRECATED] Open source alternative to UIActivityViewController, highly customizable and compatible with iOS 5.0.
Objective-C
521
star
7

RETrimControl

iOS audio trim control, similar to the one seen in default iPhone Voice Memos app.
Objective-C
288
star
8

REFormattedNumberField

UITextField subclass that allows numeric input in a predefined format.
Objective-C
201
star
9

REPhotoCollectionController

REPhotoCollectionController is a photo thumbnail viewer for the iOS that groups photos by date.
Objective-C
109
star
10

RECurtainViewController

A custom curtain-style transition for UIViewControllers.
Objective-C
81
star
11

RESwitch

Open source alternative to UISwitch, customizable via UIAppearance protocol.
Objective-C
78
star
12

REPagedScrollView

Paged UIScrollView with an embedded UIPageControl.
Objective-C
68
star
13

REValidation

Simple Objective-C object validation.
Objective-C
65
star
14

AFXAuthClient

AFNetworking Extension for XAuth Authentication.
Objective-C
58
star
15

REImageSprite

[DEPRECATED] CSS-like image sprites for iOS apps.
Objective-C
39
star
16

REDebugClient

Advanced remote Xcode logging in Terminal app.
Objective-C
37
star
17

paypal-recurring-payments

PHP PayPal Recurring Payments with Billing Agreement (could be used with cron jobs)
PHP
36
star
18

REUIKitAdditions

Category additions to UIKit.
Objective-C
28
star
19

restkit-generate

A model generator for RestKit (http://github.com/RestKit/RestKit).
Ruby
27
star
20

MapViewExample

MapView iPhone app
Objective-C
25
star
21

TableViewDataManager

Powerful data driven content manager for UITableView written in Swift.
Swift
21
star
22

paypal-express-checkout

PHP PayPal express checkout easy integration
PHP
16
star
23

iPodLyricsExample

iPodLyrics, banned from the app store
Objective-C
7
star
24

dotfiles

My dotfiles
Shell
1
star