Unity Community


Results 1 to 16 of 16

  1. Posts
    24

    How to import GPS location coordinates from Android device?

    Hello, I tried to get latitude and longitude coordinates from 'Google Nexus One' and I failed.

    I used the LocationInfo struct, but I think there is something missing. I wrote an Update function attached to 'GUI Text' like this:

    void Update()
    {
    float lat, lon;

    LocationInfo li = new LocationInfo();

    lat = li.latitude;
    lon = li.longitude;

    guiText.text="LAT= "+ lat +"\nLON= " + lon;
    }
    Always returns 0.

    Any idea? Thanks in advance,

    Joel

  2. Lead Developer



    Location
    Stockholm, Sweden
    Posts
    383
    The GPS location info is currently not supported on Android.


  3. Posts
    24
    Ok, thanks for the response.

    So, can I get GPS location info with a plugin using the NDK (or SDK) libraries from Android SDK?

    Joel

  4. Lead Developer



    Location
    Stockholm, Sweden
    Posts
    383
    Quote Originally Posted by jsr2k1 View Post
    So, can I get GPS location info with a plugin using the NDK (or SDK) libraries from Android SDK?
    Yes, by using the Java LocationManager interface (Android Dev Guide: Obtaining User Location) and a thin native wrapper between C# and Java, it shouldn't be too hard. But we will of course add this property, most probably in the very next release.


  5. Posts
    3
    Hi,

    We have been trying to create a plugin + bridge to read GPS Location at school.
    We have run into a problem which is the following:

    Using Unity 3.1.0f4, we cannot get Java plugins to work.

    On Unity 3.0, we can run the (self-built using cygwin) example Java Plugin project, but get the following error in 3.1:
    "Unable to find javabridge" (where javabridge is the name of our DLL, as used in the example, libjavabridge.so)

    This problem occurs only on 3.1.0 for the Example project and for both 3.0 and 3.1 for our own created GPS Plugin.

    Is this a known problem in the recent version of Unity and/or might there be a common mistake we are making? Like: would this error occur when we have a faulty C++ bridge?


    This problem would of course be solved if we can use GPS directly in Unity, so please do your best!

  6. Lead Developer



    Location
    Stockholm, Sweden
    Posts
    383
    Quote Originally Posted by Xandrilios View Post
    On Unity 3.0, we can run the (self-built using cygwin) example Java Plugin project, but get the following error in 3.1: "Unable to find javabridge" (where javabridge is the name of our DLL, as used in the example, libjavabridge.so)
    Did you account for the (3.1) re-arrangement in the Unity Plugin directory layout to put Android plugins under Assets/Plugins/Android (ie not only Assets/Plugins/)?


  7. Posts
    3
    I did not, will try it now. Thank you!


  8. Posts
    3
    Ok, I now screwed up my SDK install, will need to try at a later stage, sorry and thanks again.


  9. Posts
    5
    Does anybody managed to obtain the GPS Location from Android already? If yes, could you please post some instructions on how to do this?

  10. Lead Developer



    Location
    Stockholm, Sweden
    Posts
    383
    Quote Originally Posted by mikriloulou View Post
    Does anybody managed to obtain the GPS Location from Android already? If yes, could you please post some instructions on how to do this?
    GPS is supported in Unity 3.2 which is in alpha/beta state currently. But if you cant wait then the Android Developer Guide explains it in detail.


  11. Posts
    14
    Hi!

    I successfully implemented an GPS plugin for a client of mine, which in turn asked if anyone would be willing to buy it here for about 100$.
    I can't decide to give it away for free, I'm sorry.


  12. Posts
    29
    From release notes in Android section for 3.2:
    "Implemented Location Service (GPS/Wifi)."

    Lots of questions

    Have anyone tried the GPS functions in 3.2? I guess it now should work with LocationInfo? Does it work with compass as well? Any js examples on how to work with it? This might open up for some layar type features!

  13. Lead Developer



    Location
    Stockholm, Sweden
    Posts
    383
    Quote Originally Posted by krillmcrawl View Post
    Any js examples on how to work with it?
    There is a small example in the docs: iPhoneSettings.StartLocationServiceUpdates.


  14. Posts
    1

  15. ina ina is offline

    Posts
    328
    Does anyone know if LocationInfo or GPS/WiFiGPS works on Android yet? I've been getting 0's through this very simple guitxt update (both with loc reference declared in Update, and currently in Start)

    <code>
    var gtxt:GUIText;

    var loc:LocationInfo;

    function Start(){
    loc = new LocationInfo();
    }

    function Update () {

    //Debug.Log(loc.longitude);
    gtxt.text = displayLoc(loc.longitude, loc.latitude, loc.altitude, loc.horizontalAccuracy, loc.verticalAccuracy);
    }

    function displayLoc(lon:float,lat:float,alt:float,ha:float, va:float){
    return lon.ToString()+", "+lat.ToString()+" @ "+alt.ToString()+" | "+ha.ToString()+" "+va.ToString();
    }
    </code>

  16. ina ina is offline

    Posts
    328
    It's a bit misleading that the only way to start location update is to call iPhoneSettings.StartLocationServiceUpdates(); ... even on the Android.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •