Godot plugin to get current location on Android
To use this plugin you will need to compile it against your required version of Godot.
You will need:
- Android Studio https://developer.android.com/studio
- Godot AAR Library for your desired version https://godotengine.org/download/
- Open the project in Android Studio
- Put your downloaded Godot AAR Library into the
app/libs
directory. (Ensure its filename matchesgodot-lib*.aar
)
- Compile the project
- Copy the
app/build/outputs/aar/LocationPlugin.aar
file and theapp/LocationPlugin.gdap
file to theandroid/plugins
folder into your Godot app directory.
- Go to Project -> Export, select the android export, check custom build, and enable the plugin.
extends Node2D
func _ready():
// Load The plugin
var locationPlugin = Engine.get_singleton("LocationPlugin")
// Connect to the response signal
locationPlugin.connect("onCurrentLocationResponse", on_CurrentLocationResponse)
// request the current Location
locationPlugin.requestCurrentLocation()
func on_CurrentLocationResponse(locationData):
// Print the location details: { "latitude": 12.3456789, "longitude": 12.3456789 }
print(locationData)