Skip to content

Instantly share code, notes, and snippets.

@adamdriscoll
Created September 13, 2019 12:35
Show Gist options
  • Save adamdriscoll/23000bfefacf7ea76c1207fe55f171ab to your computer and use it in GitHub Desktop.
Save adamdriscoll/23000bfefacf7ea76c1207fe55f171ab to your computer and use it in GitHub Desktop.
Map Cluster Example for Universal Dashboard.
New-UDButton -Text "Add marker to cluster" -OnClick {
Add-UDElement -ParentId 'cluster-layer' -Content {
$Random = Get-Random -Minimum 0 -Maximum 100
$RandomLat = $Random + 400
New-UDMapMarker -Latitude "51.$RandomLat" -Longitude "-0.$Random"
}
}
New-UDButton -Text "Clear cluster" -OnClick {
Clear-UDElement -Id 'cluster-layer'
}
New-UDMap -Id 'map' -Endpoint {
New-UDMapLayerControl -Id 'layercontrol' -Content {
New-UDMapBaseLayer -Name "Black and White" -Content {
New-UDMapRasterLayer -TileServer 'https://tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png'
}
New-UDMapOverlay -Name "Cluster" -Content {
New-UDMapMarkerClusterLayer -Id 'cluster-layer' -Markers @(
1..100 | ForEach-Object {
$Random = Get-Random -Minimum 0 -Maximum 100
$RandomLat = $Random + 400
New-UDMapMarker -Latitude "51.$RandomLat" -Longitude "-0.$Random"
}
)
} -Checked
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment