Topic: Center the map at the user's location

Hello,

Is there a function which I can call to center the 2D map on the current user's location?

Location Services allows me to automatically center map after some period of time, which is not what I need in my case.

Currently, I'm using a custom script for checking user's location and then centering the map using:

OnlineMaps.instance.SetPosition(longitude, latitude);

Is there another way (function) designed by Online Maps for centering the map on the user location?

Or if using SetPosition is a right way, how can I get user's location from Online Maps Location Services (instead of using a custom script for it)?

Thank you!

Re: Center the map at the user's location

Hello.

OnlineMaps.SetPosition is the right way.

OnlineMapsLocationService.position
http://infinity-code.com/doxygen/online … 164baf7eb5
Important: position not available Start, because GPS is not already initialized.
Use OnLocationInited event, to determine the initialization of GPS.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Center the map at the user's location

Thank you,
Should I somehow extract the latitude and longitude from the OnlineMapsLocationService.instance.position and assign it to 2 variables and then use them as parameters for the OnlineMaps.instance.SetPositio()?

Because this way it doesn't work:
OnlineMaps.instance.SetPosition(OnlineMapsLocationService.instance.position);

Re: Center the map at the user's location

Example:

Vector2 pos = OnlineMapsLocationService.instance.position;
OnlineMaps.instance.SetPosition(pos.x, pos.y);

or

OnlineMaps.instance.position = OnlineMapsLocationService.instance.position;
Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Center the map at the user's location

Thank you very much, Alex Vertax!