mousebird-consulting-inc / WhirlyGlobe

WhirlyGlobe Development
Other
828 stars 255 forks source link

globeViewController: didSelect: Doesnt call on tap #239

Closed AndrewScherba closed 10 years ago

AndrewScherba commented 10 years ago

Init method

_globeVC = [[WhirlyGlobeViewController alloc] init];
[_containerView addSubview: _globeVC.view];
_globeVC.delegate = self;
_gloeVC.view.frame = _containerView.bounds;
_globeVC.clearColor = clearUIColor;
_globeVC.view.backgroundColor = clearUIColor;
_globeVC.pinchGesture = YES;
_globeVC.rotateGesture = YES;
_globeVC.doubleTapZoomGesture = NO;
_globeVC.autoMoveToTap = NO;
[_globeVC addSphericalEarthLayerWithImageSet:@"WordMap_info"];
_screenLabelDesc = @{kMaplyTextColor: screenLabelColor,
                    kMaplyBackgroundColor: screenLabelBackColor,
                    kMaplyFont:[UIFont systemFontOfSize:11]
                };

 [_globeVC setZoomLimitsMin: 0.05 max:1.5];
  _globeVC.keepNorthUp = YES;

add objects method:

 -(void)addCountries:(NSArray *)names stride:(int)stride{
 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0),
               ^{
                   NSMutableArray *locAutoLabels = [NSMutableArray array];
                   NSDictionary* countryPopulation =[self countriesPopulationDictionary];
                   for (NSString *name in names)
                   {
                         NSString *fileName = [[NSBundle mainBundle] pathForResource: name ofType:@".json"];
                        if (fileName)
                        {
                               NSData *jsonData = [NSData dataWithContentsOfFile:fileName];
                               if (jsonData)
                               {
                                   MaplyVectorObject *wgVecObj = [MaplyVectorObject VectorObjectFromGeoJSON:jsonData];
                                   wgVecObj.selectable = YES;
                                   NSString *vecName = [[wgVecObj attributes] objectForKey:@"name"];

                                   wgVecObj.userObject = @{@"Name":vecName?vecName:@""} ;
                                    [_globeVC addVectors:[NSArray arrayWithObject:wgVecObj]desc:nil];
                                   MaplyCoordinate center;
                                     [wgVecObj centroid:&center];

                                   MaplyScreenLabel *screenLabel = [[MaplyScreenLabel alloc] init];
                                   // Add a label right in the middle
                                   MaplyCoordinate newCoordinate;
                                   newCoordinate.x = center.x- center.x*0.05;
                                   newCoordinate.y = center.y;
                                   screenLabel.selectable = true;
                                   screenLabel.loc = newCoordinate;
                                  // screenLabel.size = CGSizeMake(0, 10);
                                   screenLabel.text = vecName;
                                   NSString* newName = [name stringByReplacingOccurrencesOfString:@".geo" withString:@""];

                                   screenLabel.userObject = screenLabel.text;
                                   if(screenLabel.text)
                                       [locAutoLabels addObject:screenLabel];
                               }
                           }
                       }

                      dispatch_async(dispatch_get_main_queue(),
                  ^{
                [_globeVC addScreenLabels:locAutoLabels desc:_screenLabelDesc];
                    });});}

Also all other method of delegate call properly, only with did select problems, (in prev build, 1 month ago, all worked good, I update from dev brunch and its doesnt work now)

mousebird commented 10 years ago

I turned off selection by default. It takes up extra memory and the vector tiles can get big.

To turn it back on, pass in kMaplySelectable: @YES when adding new vector data.... and I see that documentation doesn't reflect that. I'll update it.