I have been eager to take a look at the new Mapping Features in 2.5.0
My first test involved looking up what datasets my city had publically available so I had some content to place on a map. Turns out my city has quite a few live datasets exposed via API through it’s “OpenCity program”: http://data-cityofmadison.opendata.arcgis.com/. Using this, I was able to find some crime statistics. This was a simple set of publically released incident reports with case #'s and details for crimes in my city.
This crime info is exposed via an API so I was very easily able to do an invoke-webrequest to pull this information. Unfortunately, I was only provided with Addresses and NOT GPS Coordinates. To Facilitate this I simply used Bing Maps Locations API to turn addresses and city info into specific lat/long coords: https://docs.microsoft.com/en-us/bingmaps/rest-services/locations/find-a-location-by-address. This allowed me to place incidents from my dataset onto their real-world location.
Finally, I was able to For-Each my way through all of my retrieved incidents and place them on a map. I was able to do all of this in under an hour from start to finish - really excited to build out some new projects with this!
$HomePage = New-UDPage -Name "Home" -Icon home -Endpoint {
$Incidents = Get-Incidents
New-UDMap -Endpoint {
New-UDMapLayerControl -Content {
New-UDMapBaseLayer -Name 'Black and White' -Content {
New-UDMapRasterLayer -TileServer 'https://tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png'
} -Checked
New-UDMapBaseLayer -Name 'Color' -Content {
New-UDMapRasterLayer -TileServer 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
}
$Incidents | ForEach-Object {
$Incident = $_
New-UDMapOverlay -Name $Incident.IncidentType -Content {
New-UDMapMarker -Latitude $Incident.Latitude -Longitude $Incident.Longitude -Popup (New-UDMapPopup -Content { New-UDHeading -Text $Incident.Details })
} -Checked
}
}
} -Height '100vh'
}
I have a TON of ideas for UD Maps and will plan on sharing some more ideas as I work through some demos!