Skip to content

Unable to properly marshall data in iOS for type coordinates: interop.Pointer | interop.Reference<CLLocationCoordinate2D> #1263

@Tyler-V

Description

@Tyler-V

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 6.4.0
  • Cross-platform modules:
  • Android Runtime: 6.4.1
  • iOS Runtime: 6.4.2
  • Plugin(s):
    implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:8.6.2'
    pod 'Mapbox-iOS-SDK', '~> 5.6.1'

Describe the bug
When attempting to call methods in the mapbox sdk, I am unable to marshall the data into the correct format shown in the examples depicted in Mapbox's documentation for iOS.

In this documentation provided:

I am unable to create an object of type coordinates: interop.Pointer | interop.Reference<CLLocationCoordinate2D>

  setCameraToCoordinates(latLngs: LatLng[], padding?: number, duration?: number): Promise<void> {
    return new Promise((resolve, reject) => {
      const mapView: MGLMapView = this.view.mapView;

      let insets: UIEdgeInsets = {
        top: padding ? padding : 0,
        left: padding ? padding : 0,
        bottom: padding ? padding : 0,
        right: padding ? padding : 0,
      };

      const coordinates: CLLocationCoordinate2D[] = [];
      for (let latLng of latLngs) {
        const coordinate = CLLocationCoordinate2DMake(latLng.lng, latLng.lat);
        coordinates.push(coordinate);
      }

      const array: any = NSArray.arrayWithArray([coordinates]);

      mapView.setVisibleCoordinatesCountEdgePaddingDirectionDurationAnimationTimingFunctionCompletionHandler(
        array,
        coordinates.length,
        insets,
        0,
        duration / 1000,
        CAMediaTimingFunction.functionWithName(kCAMediaTimingFunctionEaseInEaseOut),
        () => {
          resolve();
        }
      );
    });
  }

This calls the method without error, but what is passed in is an array of CLLocationCoordinate2D that is marshalled incorrectly. I know this because instead of the provided latLngs array taking me to a central part of the US which works on Android, it takes me off the coast of Africa.

image
image

To Reproduce
Try to create a coordinates object of type interop.Pointer | interop.Reference, inspect the values created and coordinates are not correct.

Expected behavior
I should be able to create an object of type interop.Pointer | interop.Reference where the value is properly mapped and doesn't result in an improper object.

Sample project
I would be more than happy to invite you into my plugin's project which has a branch already setup and a demo-angular app which will let you bootstrap and debug this issue with minimal effort to see for yourself. Please let me know otherwise this should be easily reproducible given the steps listed above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions