1
正如我從文檔理解真正subclussing只從MKMapView。是否有可能使用GoogleMaps的Realm羣集,或者我應該尋找其他SDK?真正的聚類GMSMapView ios
正如我從文檔理解真正subclussing只從MKMapView。是否有可能使用GoogleMaps的Realm羣集,或者我應該尋找其他SDK?真正的聚類GMSMapView ios
現在ABFRealmMapView被設計爲與MKMapView
一起使用,但它可以擴展到使用Google Maps SDK。
實際進行聚類的內部組件是:ABFLocationFetchedResultsController。這允許您創建一個ABFLocationFetchRequest
描述地圖搜索,然後它將獲取這些對象,或者啓用或不啓用羣集。您可以複製類ABFRealmMapView實際使用ABFLocationFetchedResultsController
的方式,並將其移到Google地圖視圖的子類中。
導入代碼是在refreshMapView
方法,(如果啓用autorefresh
),其被自動調用響應於所述地圖被移動:
- (void)refreshMapView
{
@synchronized(self) {
[self.mapQueue cancelAllOperations];
MKCoordinateRegion currentRegion = self.region;
ABFLocationFetchRequest *fetchRequest =
[ABFLocationFetchRequest locationFetchRequestWithEntityName:self.entityName
inRealm:self.realm
latitudeKeyPath:self.latitudeKeyPath
longitudeKeyPath:self.longitudeKeyPath
forRegion:currentRegion];
if (self.basePredicate) {
NSCompoundPredicate *compPred =
[NSCompoundPredicate andPredicateWithSubpredicates:@[fetchRequest.predicate,self.basePredicate]];
fetchRequest.predicate = compPred;
}
[self.fetchResultsController updateLocationFetchRequest:fetchRequest
titleKeyPath:self.titleKeyPath
subtitleKeyPath:self.subtitleKeyPath];
typeof(self) __weak weakSelf = self;
NSBlockOperation *refreshOperation = [[NSBlockOperation alloc] init];
NSBlockOperation __weak *weakOp = refreshOperation;
MKMapRect visibleMapRect = self.visibleMapRect;
ABFZoomLevel currentZoomLevel = ABFZoomLevelForVisibleMapRect(visibleMapRect);
if (self.clusterAnnotations &&
currentZoomLevel <= self.maxZoomLevelForClustering) {
MKZoomScale zoomScale = MKZoomScaleForMapView(self);
[refreshOperation addExecutionBlock:^{
if (![weakOp isCancelled]) {
[weakSelf.fetchResultsController performClusteringFetchForVisibleMapRect:visibleMapRect
zoomScale:zoomScale];
[weakSelf addAnnotationsToMapView:weakSelf.fetchResultsController.annotations];
[weakSelf registerChangeNotification:weakSelf.autoRefresh];
}
}];
}
else {
[refreshOperation addExecutionBlock:^{
if (![weakOp isCancelled]) {
[weakSelf.fetchResultsController performFetch];
[weakSelf addAnnotationsToMapView:weakSelf.fetchResultsController.annotations];
[weakSelf registerChangeNotification:weakSelf.autoRefresh];
}
}];
}
[self.mapQueue addOperation:refreshOperation];
}
}