MKCoordinateSpanMake is undefined

Thread is closed for posting
3 posts, 1 answers
  1. TJ
    TJ avatar
    58 posts
    Member since:
    Aug 2013

    Posted 13 Feb 2015 Link to this post

    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:

  2. Answer
    Pana avatar
    748 posts

    Posted 16 Feb 2015 Link to this post


    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.


    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.

  3. TJ
    TJ avatar
    58 posts
    Member since:
    Aug 2013

    Posted 16 Feb 2015 in reply to Pana Link to this post

    Hi Pana,

    Thanks for the thorough answer. I appreciate it.

Back to Top