PowerShell, 130 Bytes
Add-Type -A System.Device;($a=[Device.Location.GeoCoordinateWatcher]::new()).Start();for(;($b=$a|% Po*n|% L*)|% I*){}$b|select L*e
Ungolfed:
Add-Type -AssemblyName System.Device #Required to access System.Device.Location namespace
$GeoWatcher = New-Object System.Device.Location.GeoCoordinateWatcher #Create the required object
$GeoWatcher.Start() #Begin resolving current locaton
whille ($GeoWatcher.Status -ne "Ready") do { sleep -Milliseconds 100 } #Wait for discovery.
$GeoWatcher.Position.Location | Select Latitude,Longitude #Select the relevent results.
Returns as:
PS C:\users\sweeneyc\Desktop> Add-Type -A System.Device;($a=[Device.Location.GeoCoordinateWatcher]::new()).Start();for(;($b=$a|% Po*n|% L*)|% I*){}$b|select L*e
Latitude Longitude
-------- ---------
53.4064177191653 -6.36202495701332
Turns out there is a way to do this, but it's not so pretty.
bonus: opens google maps on your current location.
Add-Type -A System.Device;($a=[Device.Location.GeoCoordinateWatcher]::new()).Start();for(;($b=$a|% Po*n|% L*)|% I*){};saps "https://www.google.ie/maps/@$($b.Latitude),$($b.Longitude)z"
could save 3 bytes using TryStart
but it outputs a true
to the pipeline and costs more to suppress that.
Add-Type -A System.Device;($a=[Device.Location.GeoCoordinateWatcher]::new()).TryStart($true,[int]9e8);$a|% Po*n|% L*|select L*e
PowerShell (non-competing), 44 Bytes
(irm freegeoip.net/xml).Response|select *ude
Uses an external service since PowerShell has no internal builtins for 'current location' - this is IP-based Geolocation, so almost definitely won't return your actual location, it will return a 'default' location for your ISP, and if you run this over a VPN will present wherever the exit point is.
I've tried (not as a golf exercise) to get google maps API to work with the wireless-mac-address geolocation method, but it's far from accurate or golfable.
marked as non-competing due to the inaccuracy of the results.
PS C:\Users\sweeneyc> (irm freegeoip.net/xml).Response|select *ude
Latitude Longitude
-------- ---------
53.3472 -6.2439
this displays Central Dublin, Ireland
when searched up, however i'm a bit outside the city center currently, about 8 miles from the returned point.
gl
forGet-Location
, sadly I don't thinkC:\Users\Connor
will help you escape the forest very much. \$\endgroup\$