Opening map using addressDictionary results in unknown location

214 views
Skip to first unread message

Andrea Campolonghi

unread,
Jan 16, 2014, 8:38:27 AM1/16/14
to rubym...@googlegroups.com
I am porting an application from a Objective-c test case into a ruby motion production app. I am facing an issue opening a map using MKMapItem.

The following code works ok in objective-c:

Enter code here...NSDictionary *address = @{
                              (NSString *)kABPersonAddressStreetKey: [self.location objectForKey:@"street"],
                              (NSString *)kABPersonAddressCityKey: [self.location objectForKey:@"city"],
                              (NSString *)kABPersonAddressStateKey: [self.location objectForKey:@"state"],
                              (NSString *)kABPersonAddressZIPKey: [self.location objectForKey:@"zip"]
                              };
    
    CLLocationCoordinate2D coordinates = CLLocationCoordinate2DMake(
                                                                    (CLLocationDegrees)[[self.location objectForKey:@"latitude"] floatValue],
                                                                    (CLLocationDegrees)[[self.location objectForKey:@"longitude"] floatValue]
                                                                    );
    MKPlacemark *place = [[MKPlacemark alloc] initWithCoordinate:coordinates addressDictionary:address];
    MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:place];
    NSDictionary *options = @{};
    [mapItem openInMapsWithLaunchOptions:options];


While the translated code to ruby motion does not recognise the addressDictionary Hash and opens map with 'Unknown Location'

address_dictionary = {
        :kABPersonAddressStreetKey => street,
        :kABPersonAddressCityKey => city,
        :kABPersonAddressStateKey => state,
        :kABPersonAddressZIPKey => zip
    }
    place = MKPlacemark.alloc.initWithCoordinate(coordinate, addressDictionary: address_dictionary)
    item = MKMapItem.alloc.initWithPlacemark(place)
    item.openInMapsWithLaunchOptions({})



 address_dictionary has the correct value setted in but for some reason is not parsed or translated correctly.


Any suggestion?

Colin T.A. Gray

unread,
Jan 16, 2014, 8:59:31 AM1/16/14
to rubym...@googlegroups.com
here's one thing I notice: those constants should be written as "KABPersonAddressCityKey", not ":kABPersonAddressCityKey"


Colin T.A. Gray
Community Manager
HipByte


--
You received this message because you are subscribed to the Google Groups "RubyMotion - Ruby for iOS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubymotion+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubymotion/9cccfa67-46cf-4e3c-b145-d567fed07866%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Andrea Campolonghi

unread,
Jan 16, 2014, 9:02:20 AM1/16/14
to rubym...@googlegroups.com
You are great man!!!
Working fine now.

Thanks

16 Jan 2014 14:59
here's one thing I notice: those constants should be written as "KABPersonAddressCityKey", not ":kABPersonAddressCityKey"


Colin T.A. Gray
Community Manager
HipByte



On January 16, 2014 at 6:38:35 AM, Andrea Campolonghi (acampo...@gmail.com) wrote:

--
You received this message because you are subscribed to a topic in the Google Groups "RubyMotion - Ruby for iOS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rubymotion/bTNtl9sw-eE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rubymotion+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubymotion/etPan.52d7e5c3.74b0dc51.472f%40Goose.local.

For more options, visit https://groups.google.com/groups/opt_out.
16 Jan 2014 14:38
You received this message because you are subscribed to a topic in the Google Groups "RubyMotion - Ruby for iOS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rubymotion/bTNtl9sw-eE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rubymotion+...@googlegroups.com.

--
Andrea Campolonghi

Reply all
Reply to author
Forward
0 new messages