Initialising map to location without using default

  • Issue category: Lightship Maps
  • Device type & OS version: Android
  • Host machine & OS version: Windows 11
  • Issue Environment : Unity Editor
  • Xcode version:
  • ARDK version:
  • Unity version: 2022.50f

Description of the issue:
Hello !

I’m trying to initialise the map at given coordinates. I saw this topic suggesting to use the SetViewableArea() method, but it doesn’t work, because the _unitConverter field is null.

I’ve also tried using SetMapCenter but nothing happens, even when calling RefreshMap() after.
If I leave “Start At Default Location” to true, the map gets initialised perfectly. But I want to initialise it based on User Input, on this side of the app.

Any advice for having this behaviour? Thanks a lot.

Hi Mattéo,

Unfortunately, this is a known bug with the current release of Lightship Maps. A workaround you can try is disabling the game object containing the map, setting the default location coordinates to the user’s input, leaving Start at Default Location to true, and then enabling the game object.

Kind regards,
Maverick L.

1 Like

Thank you Maverick. Good, I’m not crazy ! But the problem is, the _defaultLocation field is private. You can’t change it through code.

I guess I could copy the class and make another one with these changes, in the meantime.

Here’s what I used to make it work :

public void SetMapOrigin(float lat, float lng)
    {
        Debug.Log($"Setting map origin to lat : {lat} and lng : {lng}");
        SerializableLatLng latLng = new(lat, lng);
        lightShipMapView.defaultLocation = latLng;
        lightShipMapView.gameObject.SetActive(true);
    }

Problem is you’ve got to make the field public. If the package changes, that change will be reverted as well.

You’re very welcome! In a future release of Lightship Maps this will be corrected. I’m glad to hear you got it working!

1 Like