Overlay Images and Overlay Views with MapKit Tutorial

Discussion of the official tutorials published on raywenderlich.com. Please only discuss the official tutorials here - for general questions, use the General Discussion forum instead.

Overlay Images and Overlay Views with MapKit Tutorial

Postby rwenderlich » Tue Mar 05, 2013 11:00 am

This is the official thread to discuss the following blog post: Overlay Images and Overlay Views with MapKit Tutorial
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ray Wenderlich
Blog: http://www.raywenderlich.com
Twitter: http://twitter.com/rwenderlich
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
User avatar
rwenderlich
Team Member
Site Admin
 
Posts: 2175
Joined: Thu Dec 23, 2010 4:14 pm
Has thanked: 28 times
Been thanked: 350 times

Re: Overlay Images and Overlay Views with MapKit Tutorial

Postby shippo0708 » Wed Mar 06, 2013 3:53 am

How different is the API between MapKit and Google Maps API?
User avatar
shippo0708
Uber Haxx0r
 
Posts: 682
Joined: Fri Apr 15, 2011 4:06 am
Location: Texas
Has thanked: 2 times
Been thanked: 51 times

Re: Overlay Images and Overlay Views with MapKit Tutorial

Postby cwagdev » Wed Mar 06, 2013 3:56 am

shippo0708 wrote:How different is the API between MapKit and Google Maps API?


As far as the iOS side goes, there really is no difference that I am aware of. They left the interfaces/APIs the same for MapKit and just changed the underlying implementations.
User avatar
cwagdev
Team Member
iOS Tutorial Team Member
 
Posts: 117
Joined: Mon May 14, 2012 8:41 pm
Has thanked: 8 times
Been thanked: 11 times

Re: Overlay Images and Overlay Views with MapKit Tutorial

Postby elpuerco63 » Thu Mar 07, 2013 8:32 pm

I'm getting an error in the initWithFilename method of PVPark.m for _overlayTopRightCoordinate stating this property is not found?

I have even copy / pasted the sample code from the tutorial and get the same error.

When I look at the auto complete of the properties I only see three in the list, _overlayBottomLeftCoordinate, _overlayBottomRightCoordinate and _overlayTopLeftCoordinate

:?
elpuerco63
Uber Haxx0r
 
Posts: 281
Joined: Tue Jun 28, 2011 10:16 am
Has thanked: 8 times
Been thanked: 7 times

Re: Overlay Images and Overlay Views with MapKit Tutorial

Postby akonakov » Thu Mar 07, 2013 8:58 pm

elpuerco63 wrote:I'm getting an error in the initWithFilename method of PVPark.m for _overlayTopRightCoordinate stating this property is not found?

Check if you really have the following additional getter, but not the getter for overlayTopRightCoordinate:

Code: Select all
- (CLLocationCoordinate2D)overlayBottomRightCoordinate
{
    return CLLocationCoordinate2DMake(self.overlayBottomLeftCoordinate.latitude, self.overlayTopRightCoordinate.longitude);
}
User avatar
akonakov
Hacker
 
Posts: 35
Joined: Wed May 02, 2012 5:21 am
Has thanked: 3 times
Been thanked: 2 times

Re: Overlay Images and Overlay Views with MapKit Tutorial

Postby cwagdev » Thu Mar 07, 2013 9:25 pm

elpuerco63 wrote:I'm getting an error in the initWithFilename method of PVPark.m for _overlayTopRightCoordinate stating this property is not found?

I have even copy / pasted the sample code from the tutorial and get the same error.

When I look at the auto complete of the properties I only see three in the list, _overlayBottomLeftCoordinate, _overlayBottomRightCoordinate and _overlayTopLeftCoordinate

:?


Verify that PVPark.h declares the property.

Code: Select all
@property (nonatomic, readonly) CLLocationCoordinate2D overlayTopRightCoordinate;
User avatar
cwagdev
Team Member
iOS Tutorial Team Member
 
Posts: 117
Joined: Mon May 14, 2012 8:41 pm
Has thanked: 8 times
Been thanked: 11 times

Re: Overlay Images and Overlay Views with MapKit Tutorial

Postby cwagdev » Thu Mar 07, 2013 9:27 pm

akonakov wrote:
elpuerco63 wrote:I'm getting an error in the initWithFilename method of PVPark.m for _overlayTopRightCoordinate stating this property is not found?

Check if you really have the following additional getter, but not the getter for overlayTopRightCoordinate:

Code: Select all
- (CLLocationCoordinate2D)overlayBottomRightCoordinate
{
    return CLLocationCoordinate2DMake(self.overlayBottomLeftCoordinate.latitude, self.overlayTopRightCoordinate.longitude);
}


There's actually not a defined getter for overlayTopRightCoordinate, it is a defined property and assigned. overlayBottomRightCoordinate happens to be a property that can be inferred, so that is the reason I went with having an custom getter for it.
User avatar
cwagdev
Team Member
iOS Tutorial Team Member
 
Posts: 117
Joined: Mon May 14, 2012 8:41 pm
Has thanked: 8 times
Been thanked: 11 times

Re: Overlay Images and Overlay Views with MapKit Tutorial

Postby elpuerco63 » Fri Mar 08, 2013 7:22 am

akonakov wrote:
elpuerco63 wrote:I'm getting an error in the initWithFilename method of PVPark.m for _overlayTopRightCoordinate stating this property is not found?

Check if you really have the following additional getter, but not the getter for overlayTopRightCoordinate:

Code: Select all
- (CLLocationCoordinate2D)overlayBottomRightCoordinate
{
    return CLLocationCoordinate2DMake(self.overlayBottomLeftCoordinate.latitude, self.overlayTopRightCoordinate.longitude);
}



Cha ching!

Thanks :D
elpuerco63
Uber Haxx0r
 
Posts: 281
Joined: Tue Jun 28, 2011 10:16 am
Has thanked: 8 times
Been thanked: 7 times

Re: Overlay Images and Overlay Views with MapKit Tutorial

Postby elpuerco63 » Fri Mar 08, 2013 7:27 am

This bit of code confuses me only due to the fact that boundary is declared as CLLocationCoordinate2D and not an NSArray?

I understand the setting of memory allocation using malloc but not about why you are doing it this way?

Is there an advantage in doing it this way over using NSArray and its addObject method?

Code: Select all

@property (nonatomic, readonly) CLLocationCoordinate2D *boundary;


 _boundary = malloc(sizeof(CLLocationCoordinate2D)*_boundaryPointsCount);
       
        for(int i = 0; i < _boundaryPointsCount; i++) {
            CGPoint p = CGPointFromString(boundaryPoints[i]);
            _boundary[i] = CLLocationCoordinate2DMake(p.x,p.y);
        }
elpuerco63
Uber Haxx0r
 
Posts: 281
Joined: Tue Jun 28, 2011 10:16 am
Has thanked: 8 times
Been thanked: 7 times

Re: Overlay Images and Overlay Views with MapKit Tutorial

Postby tamarawirz » Fri Mar 08, 2013 8:09 am

Thanks for the tutorial!
Last edited by tamarawirz on Fri Mar 08, 2013 10:37 am, edited 1 time in total.
TWE LLC
User avatar
tamarawirz
Subscriber since Feb 14, 2014
Hacker
 
Posts: 19
Joined: Sat Aug 13, 2011 7:47 pm
Location: Texas
Has thanked: 6 times
Been thanked: 0 time

Next

Return to Official Tutorials

Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 8 guests