Created
September 16, 2019 10:07
-
-
Save adamdriscoll/8810602070c8a5b26f789ced3882d462 to your computer and use it in GitHub Desktop.
Dynamically add markers to a map using geocoding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Dashboard = New-UDDashboard -Title "PowerShell Conference Asia 2019" -Content { | |
New-UDMap -Id 'map' -Endpoint { | |
New-UDMapLayerControl -Id 'layercontrol' -Content { | |
New-UDMapBaseLayer -Name "Bing" -Content { | |
New-UDMapRasterLayer -Bing -ApiKey '11111111' -Type Road | |
} -Checked | |
New-UDMapOverlay -Name "Cluster" -Content { | |
New-UDMapMarkerClusterLayer -Id 'cluster-layer' -Markers @( | |
) | |
} -Checked | |
} | |
} | |
New-UDTextbox -Id 'txtAddress' -Label 'Address' | |
New-UDButton -Text "Add marker to cluster" -OnClick { | |
$Address = (Get-UDElement -Id 'txtAddress').Attributes['value'] | |
$item = Invoke-RestMethod "https://geocoder.cit.api.here.com/6.2/geocode.json?searchtext=$Address&app_id=1111111&app_code=12213123121&gen=8" | |
$position = $item.response.view.result.location.displayposition | |
Add-UDElement -ParentId 'cluster-layer' -Content { | |
New-UDMapMarker -Latitude $position.latitude -Longitude $position.longitude | |
} -Broadcast | |
Show-UDToast -Message "Added marker for $Address" -Broadcast | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment