Skip to content
This repository has been archived by the owner on May 9, 2018. It is now read-only.

Coordinates become 0 no matter what I set them too. (centerCoordinate) using RMTileSource #306

Open
SudoPlz opened this issue Sep 11, 2013 · 6 comments
Labels

Comments

@SudoPlz
Copy link

SudoPlz commented Sep 11, 2013

My code is this

//Creating the point
CLLocationCoordinate2D centerPoint;
 centerPoint.latitude = 36.966029;
 centerPoint.longitude = -121.977739;

//print out its contents
NSLog(@"Coords should be: lat %f,long %f ", centerPoint.latitude,centerPoint.longitude);

// create the map view
_map = [[RMMapView alloc]
            initWithFrame: self.view.bounds
            andTilesource:cartoSource
            centerCoordinate:centerPoint
            zoomLevel:6
            maxZoomLevel:18
            minZoomLevel:1
            backgroundImage:nil];

//print out its centerCoordinates
NSLog(@"NEW coords: lat %f,long %f ", _map.centerCoordinate.latitude,_map.centerCoordinate.longitude);

//set the center coordinates AGAIN
[_map setCenterCoordinate:centerPoint animated:0];

//print out centerCoordinates
NSLog(@"NEW coords: lat %f,long %f ", _map.centerCoordinate.latitude,_map.centerCoordinate.longitude);

The NSLogs print out the following:

Coords should be: lat 36.966029,long -121.977739 
NEW coords: lat 0.000000,long 0.000000 
NEW coords: lat 0.000000,long 0.000000 
NEW coords: lat 0.000000,long 0.00 000

No matter what coordinates I set my centerCoordinate to, it is always 0.
The same does not happen when I use another constructor like
say
[initWithFrame:];

What am I doing wrong? Is this a bug?

@incanus
Copy link
Contributor

incanus commented Sep 11, 2013

See also Outdooractive/route-me#134

@incanus
Copy link
Contributor

incanus commented Sep 11, 2013

Where are you doing this? Maybe in viewDidLoad before things actually appear? Try this in viewDidAppear: or similar since IIRC the scroll view backing the map needs to be added to the visible view hierarchy for things to change.

@SudoPlz
Copy link
Author

SudoPlz commented Sep 12, 2013

I was indeed using it in viewDidLoad. I did change it to viewDidAppear and I get the same exact result.
This has to be a bug..

@SudoPlz
Copy link
Author

SudoPlz commented Sep 12, 2013

In case this helps, this is my RMTileSource delegate implementation. (I follow the <RMTileSource> protocol)

@synthesize img;
@synthesize minZoom;
@synthesize maxZoom;
@synthesize cacheable;
@synthesize opaque;
@synthesize mercatorToTileProjection;
@synthesize projection;
@synthesize latitudeLongitudeBoundingBox;
@synthesize uniqueTilecacheKey;
@synthesize tileSideLength;
@synthesize shortName;
@synthesize longAttribution;
@synthesize longDescription;
@synthesize shortAttribution;

-(void)justAnInitFunction
{
    minZoom = 1;                //cant be null
    maxZoom = 17;                //cant be null
    cacheable = YES;
    opaque = YES;
    //    mercatorToTileProjection;
    //    projection;
    //    latitudeLongitudeBoundingBox;
    //    uniqueTilecacheKey;
    tileSideLength = 256;       //cant be null
    shortName = @"SourceName";
    //    longAttribution;
    longDescription = @"A tile source getting fed by my bitmaps.";
    //    shortAttribution;
}



- (UIImage *)imageForTile:(RMTile)tile inCache:(RMTileCache *)tileCache
{
    //for testing purposes, I feed the img with just a plain jpeg

    img = [UIImage imageWithContentsOfFile:
     [[NSBundle mainBundle] pathForResource:@"bird" ofType:@"jpeg"]
     ];
    return img;
}



- (BOOL)tileSourceHasTile:(RMTile)tile
{
    return YES;
}

- (void)didReceiveMemoryWarning
{
}
- (void)cancelAllDownloads
{
}

@incanus
Copy link
Contributor

incanus commented Aug 27, 2014

@SudoPlz Do you still see this in develop? There have been some instantiation fixes there recently.

@SudoPlz
Copy link
Author

SudoPlz commented Aug 27, 2014

Sorry incanus its been a year now. I have no time to check this right now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants