Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Add-Type -AssemblyName System.Windows.Forms
- Add-Type -AssemblyName System.Drawing
- Add-Type -AssemblyName System.Web
- $form = New-Object System.Windows.Forms.Form
- $form.Size = New-Object System.Drawing.Size(800,600)
- $webBrowser = New-Object System.Windows.Forms.WebBrowser
- $webBrowser.Dock = 'Fill'
- $webBrowser.ScriptErrorsSuppressed = $true
- $webBrowser.AllowWebBrowserDrop = $false
- $webBrowser.IsWebBrowserContextMenuEnabled = $false
- $webBrowser.WebBrowserShortcutsEnabled = $false
- # Coordonnées par défaut (Paris)
- $global:defaultLatitude = 48.8566
- $global:defaultLongitude = 2.3522
- # Création de la fenêtre principale
- $mainWindow = New-Object System.Windows.Forms.Form
- $mainWindow.Text = 'Google Maps'
- $mainWindow.ClientSize = New-Object System.Drawing.Size(550, 500)
- $mainWindow.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
- $mainWindow.MaximizeBox = $false
- $mainWindow.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterScreen
- # Création du contrôle WebBrowser
- $webBrowser = New-Object System.Windows.Forms.WebBrowser
- $webBrowser.Dock = [System.Windows.Forms.DockStyle]::Fill
- $webBrowser.ScriptErrorsSuppressed = $true
- $webBrowser.Navigate("https://www.google.com/maps?q=&layer=c&cbll=$global:defaultLatitude,$global:defaultLongitude&cbp=11.54,,0,0,-15")
- # Création de la zone de recherche
- $searchBox = New-Object System.Windows.Forms.TextBox
- $searchBox.Location = New-Object System.Drawing.Point(200, 8)
- $searchBox.Size = New-Object System.Drawing.Size(100, 20)
- $searchBox.Add_KeyDown({
- if ($_.KeyCode -eq 'Enter') {
- $webBrowser.Navigate("https://www.google.com/maps?q=" + [System.Web.HttpUtility]::UrlEncode($searchBox.Text))
- }
- })
- # Bouton "Retour à Street View"
- $returnToStreetViewButton = New-Object System.Windows.Forms.Button
- $returnToStreetViewButton.Location = New-Object System.Drawing.Point(390, 8)
- $returnToStreetViewButton.Size = New-Object System.Drawing.Size(150, 25)
- $returnToStreetViewButton.Text = 'Return to Street View'
- $returnToStreetViewButton.Add_Click({
- $url = "https://www.google.com/maps?q=&layer=c&cbll=$global:defaultLatitude,$global:defaultLongitude&cbp=11.54,,0,0,-15"
- $webBrowser.Navigate($url)
- })
- $altitudeLabel = New-Object System.Windows.Forms.Label
- $altitudeLabel.Location = New-Object System.Drawing.Point(10, 40)
- $altitudeLabel.AutoSize = $true
- $longitudeLabel = New-Object System.Windows.Forms.Label
- $longitudeLabel.Location = New-Object System.Drawing.Point(10, 70)
- $longitudeLabel.AutoSize = $true
- $latitudeLabel = New-Object System.Windows.Forms.Label
- $latitudeLabel.Location = New-Object System.Drawing.Point(10, 100)
- $latitudeLabel.AutoSize = $true
- $webBrowser.Add_Navigated({
- if ($webBrowser.Url.AbsoluteUri -match '/@([0-9.-]+),([0-9.-]+),') {
- $lat = $matches[1]
- $long = $matches[2]
- $searchBox.Text = ''
- # Extraction de l'altitude à partir de l'URL
- if ($webBrowser.Url.AbsoluteUri -match '/@([0-9.-]+),([0-9.-]+),([0-9]+z)') {
- $altitude = $matches[3]
- $altitudeLabel.Text = "Altitude : $altitude m"
- }
- else {
- $altitudeLabel.Text = "Altitude non trouvée"
- }
- # Extraction de la longitude à partir de l'URL
- if ($webBrowser.Url.AbsoluteUri -match '/@([0-9.-]+),([0-9.-]+),') {
- $longitude = $matches[2]
- $longitudeLabel.Text = "Longitude : $longitude"
- $global:defaultLongitude = $longitude
- }
- else {
- $longitudeLabel.Text = "Longitude non trouvée"
- }
- # Extraction de la latitude à partir de l'URL
- if ($webBrowser.Url.AbsoluteUri -match '/@([0-9.-]+),([0-9.-]+),') {
- $latitude = $matches[1]
- $latitudeLabel.Text = "Latitude : $latitude"
- $global:defaultLatitude = $latitude
- }
- else {
- $latitudeLabel.Text = "Latitude non trouvée"
- }
- }
- })
- $form.Controls.Add($searchBox)
- $form.Controls.Add($searchButton)
- $form.Controls.Add($returnToStreetViewButton)
- $form.Controls.Add($altitudeLabel)
- $form.Controls.Add($latitudeLabel)
- $form.Controls.Add($longitudeLabel)
- $form.Controls.Add($webBrowser)
- $form.WindowState = 'Maximized'
- [void] $form.ShowDialog()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement