Example of Plotting a Windows 10 PCs Location on a Map using New-UDMap
function Get-GPSLocation() {
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
while (($GeoWatcher.Status -ne 'Ready') -and ($GeoWatcher.Permission -ne 'Denied')) {
Start-Sleep -Milliseconds 100 #Wait for discovery.
}
if ($GeoWatcher.Permission -eq 'Denied'){
Write-Error 'Access Denied for Location Information'
} else {
$GeoWatcher.Position.Location | Select Latitude,Longitude #Select the relevent results.
}
}
$Dashboard = New-UDDashboard -title "PC Location" -content {
new-udcard -Size medium -Content {
New-UDMap -Endpoint {
[double]$lat = @(Get-GPSLocation).Latitude
[double]$lon = @(Get-GPSLocation).Longitude
$BeerIcon = New-UDMapIcon -Url 'http://www.henningweb.net/images/pc.png' -Height 32 -Width 32
New-UDMapRasterLayer -TileServer 'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png'
New-UDMapMarker -icon $BeerIcon -Latitude $lat -Longitude $lon -Popup (New-UDMapPopup -Content { new-udcard -text "$env:computername" -Size small })
New-UDMapVectorLayer -Circle -Radius 250 -Latitude $lat -Longitude $lon -color blue -Opacity .5 -FillOpacity .1 -fillcolor blue
} -Longitude $lon -Latitude $lat -zoom 16 -height 50ch }
}
Get-UDDashboard | Stop-UDDashboard
Start-UDDashboard -Dashboard $Dashboard -Port 10000 -AutoReload
Let me know if you find it useful