This is a migrated thread and some comments may be shown as answers.

MKCoordinateSpanMake is undefined

2 Answers 347 Views
NativeScript Insiders
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
TJ
Top achievements
Rank 1
TJ asked on 13 Feb 2015, 04:23 PM
Hey all,

I'm working on porting some map code from Objective-C to NativeScript and I ran into this issue. Basically console.log( typeof MKCoordinateSpanMake ) logs undefined, and I'm not sure why, because my other mapping classes are all available. Here's the iOS API docs on it: https://developer.apple.com/library/mac/documentation/MapKit/Reference/MapKitFunctionsReference/index.html#//apple_ref/c/func/MKCoordinateSpanMake.

Thanks,
TJ

2 Answers, 1 is accepted

Sort by
0
Accepted
Pana
Telerik team
answered on 16 Feb 2015, 03:08 PM
Hi,

MKCoordinateSpanMake is an inline function. This means it has its implementation defined in its header, but does not emit native code in the native library. Similar functions are not available in NativeScript. The function is declared as:

NS_INLINE MKCoordinateSpan MKCoordinateSpanMake(CLLocationDegrees latitudeDelta, CLLocationDegrees longitudeDelta)
{
    MKCoordinateSpan span;
    span.latitudeDelta = latitudeDelta;
    span.longitudeDelta = longitudeDelta;
    return span;
}

Anytime you use that function the native compiler will replace your C or Objective-C code with the function's implementation. However NativeScript does not translate the C code there to JavaScript. If you want to use it it would be best to write your own JavaScript utility function that does something like:

function MKCoordinateSpanMake(latitudeDelta, longitudeDelta) {
    return { latitudeDelta: latitudeDelta, longitudeDelta: longitudeDelta };
}

When the so created JavaScript object is used in a function that expects MKCoordinateSpan it will be marshaled to a C struct on the native side. There are still differences though the JavaScript does not support providing arguments by value.

In addition we are currently working on documentation for the iOS specific APIs and the inline functions topic will be included.

Regards,
Pana
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
TJ
Top achievements
Rank 1
answered on 16 Feb 2015, 06:35 PM
Hi Pana,

Thanks for the thorough answer. I appreciate it.

TJ 
Tags
NativeScript Insiders
Asked by
TJ
Top achievements
Rank 1
Answers by
Pana
Telerik team
TJ
Top achievements
Rank 1
Share this question
or