# Initializing Lightship map with runtime custom coordinates

**URL:** <https://community.nianticspatial.com/t/initializing-lightship-map-with-runtime-custom-coordinates/3899>\
**Category:** I'm Stuck\
**Created:** [October 4, 2023, 10:49pm UTC](https://community.nianticspatial.com/t/initializing-lightship-map-with-runtime-custom-coordinates/3899 "2023-10-04T22:49:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lorenzo](https://avatars.discourse-cdn.com/v4/letter/l/4da419/32.png) [@lorenzo](https://community.nianticspatial.com/u/lorenzo)\
**Post date:** [October 4, 2023, 10:49pm UTC](https://community.nianticspatial.com/t/initializing-lightship-map-with-runtime-custom-coordinates/3899/1 "2023-10-04T22:49:20Z")

</div>

- **Issue category** : Lightship Maps
- **Device type & OS version** : Android / iOS
- **Unity version** : 2022.3.10f1

**Description of the issue:**

Hello everyone,

I am a Unity beginner and I’m trying to use Niantic’s Lightship for the first time.  
My goal is to initialize the map to focus on a specific location obtained from the device’s GPS coordinates.

I have already created a class responsible for fetching GPS coordinates, and I’ve identified a step in the `Awake()` method of the `LightshipMapView` script that appears to be involved:

```auto
if (_startAtDefaultLocation)
{
    _unitConverter = InitializeUnitConverter(_defaultLocation);
    SetViewableArea(_unitConverter.MapOrigin, _viewableRadius);
}

```

To achieve my goal, I’d like to use the class that provides GPS coordinates to pass them to `InitializeUnitConverter()` and then to `SetViewableArea()` like this:

```auto
{
    SerializableLatLng GPSCoordinate = new SerializableLatLng(GPSCoordProvider.lat, GPSCoordProvider.long);
    _unitConverter = InitializeUnitConverter(GPSCoordinate);
    SetViewableArea(_unitConverter.MapOrigin, _viewableRadius);
}

```

The issue I’m facing is that I can’t use an external class outside of the Niantic package. In this case, the class I’ve created as part of my assets (GPSCoordProvider) can’t be imported into Niantic’s `LightshipMapView` class because it belongs to the asset package, not the Niantic package.

I have a feeling that there’s something I haven’t fully understood about how packages work, or there might be a different way to achieve my goal.  
If I can figure this out I will be clear on how to carry out the rest .  
I would greatly appreciate any ideas or suggestions on this matter.

---

<div class="post-metadata">

**Author:** ![Maverick\_Niantic](https://avatars.discourse-cdn.com/v4/letter/m/8edcca/32.png) [@Maverick\_Niantic](https://community.nianticspatial.com/u/Maverick_Niantic)\
**Post date:** [October 5, 2023, 4:59pm UTC](https://community.nianticspatial.com/t/initializing-lightship-map-with-runtime-custom-coordinates/3899/2 "2023-10-05T16:59:10Z")

</div>

Hi Lorenzo,

Welcome to Lightship!

For something like this, you wouldn’t edit LightshipMapView.cs directly. Instead, you could attach your own MonoBehaviour to the game object holding the LightshipMapView, capture the LightshipMapView script in the Awake function, and call the #SetViewableArea() function.

```
LightshipMapView mapView;void Awake(){  mapView = gameObject.GetComponent<LightshipMapView>();}void Start(){  LatLng coords = new LatLng(GPSCoordProvider.lat, GPSCoordProvider.long);  mapView.SetViewableArea(coords, mapView.MapRadius);}

```

Don’t worry about serializable versions right now. When in doubt, check the API Reference for public members, methods, structures, and classes as those are the anticipated “points of entry” for your external code.

LightshipMapView API Reference:  
[https://lightship.dev/docs/beta/maps/apiref/Niantic/Lightship/Maps/class\_LightshipMapView/](https://lightship.dev/docs/beta/maps/apiref/Niantic/Lightship/Maps/class_LightshipMapView/)

LatLng is a public structure you can import and instantiate: [https://lightship.dev/docs/beta/maps/apiref/Niantic/Lightship/Maps/Core/Coordinates/struct\_LatLng/](https://lightship.dev/docs/beta/maps/apiref/Niantic/Lightship/Maps/Core/Coordinates/struct_LatLng/)

Kind Regards,  
Maverick L.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/niantic/user_avatar/community.nianticspatial.com/system/32/13_2.png) [@system](https://community.nianticspatial.com/u/system)\
**Post date:** [October 5, 2023, 7:20pm UTC](https://community.nianticspatial.com/t/initializing-lightship-map-with-runtime-custom-coordinates/3899/3 "2023-10-05T19:20:43Z")

</div>

Closed on October 5, 2023, 7:20pm UTC

This topic was automatically closed 2 hours after the last reply. New replies are no longer allowed.
