- Home /
How to get GPS coordinates in unity 3d
Hi All,
How to access the GPS coordinates in unity3d for Android application.
Please guide me in steps to know about GPS coordinates.
Thank you in Advance.......
Hi Please let me know if you have found the solution for this problem as I am facing the same issue
Answer by Seth-Bergman · Nov 09, 2012 at 06:02 AM
step 1. look here:
http://docs.unity3d.com/Documentation/ScriptReference/LocationInfo.html
http://docs.unity3d.com/Documentation/ScriptReference/LocationService.html
Well, that about covers it
Seriously though, you need to start it through input, with the line:
Input.location.Start();
here's the Script Example: http://docs.unity3d.com/Documentation/ScriptReference/LocationService.Start.html
http://docs.unity3d.com/Documentation/ScriptReference/Input-location.html?from=LocationService
Thank you for your Valuable reply.
I tested to get GPS coordinates as you mentioned in the above link. But it is showing an error messages as:
BCE0019: 'latitude' is not a member of 'UnityEngine.LocationService'. BCE0019: 'longitude' is not a member of 'UnityEngine.LocationService'.
The same error is showing for all the remaining values of altitude, horizontalAccuracy and timestamp.
Please explain briefly to get GPS co-ordinates.
Thank you in advance...
0
I solved the above errors.
I just changed lines Input.location.lastData.longitude ins$$anonymous$$d of Input.location.longitude
After solving the problem it just showing the location as (0,0,0,0). I am running this script by attaching to $$anonymous$$ainCamera in unity3d.
I din't used any of the devices. Please explain Which are the things required to show the location ?
Thank you in advance....
I solved the problem of above errors.
I just changed lines Input.location.lastData.longitude ins$$anonymous$$d of Input.location.longitude
After solving the problem it just showing the location as (0,0,0,0). I am running this script by attaching to $$anonymous$$ainCamera in unity3d.
I din't used any of the devices. Please explain Which are the things required to show the location ?
Thank you in advance....
Answer by ejpaari · Nov 12, 2013 at 07:31 AM
Here is an example: http://docs.unity3d.com/Documentation/ScriptReference/LocationService.Start.html
Just make sure you have checked "Input.location.isEnabledByUser", "Input.location.Start();" and "Input.location.status" like in the example above.
In addition if you want to make conversions you can start here: http://en.wikipedia.org/wiki/Latitude#The_length_of_a_degree_of_latitude
Answer by ethanlish · Sep 07, 2019 at 09:28 AM
Make sure that you update player settings to allow 'Promotion support' and add text to 'Location Usage Description'
Thanks, E,Make sure in player settings you check 'Promotion support' and add some text to 'Location Usage Description'
E