Google Streetview

Mar 20, 2009 at 3:39 PM
Hello,

Should it be possible to add StreetView functionality in the new version? Something like a property that displays if it is available on the currentposition, and if it is, you can use some kind of StreetView object.

With kind regards,
Thomas
Coordinator
Mar 21, 2009 at 10:47 AM
interesting idea!
Coordinator
Mar 24, 2009 at 7:28 PM
investigaion done!

http://maps.google.com/cbk?output=xml&ll=37.4451,-122.125577

<?xml version="1.0" encoding="UTF-8" ?><panorama><data_properties image_width="3328" image_height="1664" 
tile_width="512" tile_height="512" pano_id="MEq4lb99CK5i6du2n7W8bQ" num_zoom_levels="3" lat="37.445115" 
lng="-122.125611" ><copyright>© 2009 Google</copyright><text>Santa Catalina 
St</text><street_range>2346</street_range><region>Palo Alto, CA</region><country>United 
States</country></data_properties><projection_properties projection_type="spherical" pano_yaw_deg="308.26" 
tilt_yaw_deg="96.90" tilt_pitch_deg="0.85" /><annotation_properties ><link yaw_deg="129.69" 
pano_id="vHkNrnZde-WRSGM3kRwxYQ" road_argb="0x80ffffff" ><link_text>Santa Catalina 
St</link_text></link><link yaw_deg="309.69" pano_id="N_qgmGzNxIfXxfmFOAS8WA" road_argb="0x80ffffff" 
><link_text>Santa Catalina St</link_text></link></annotation_properties></panorama>

http://cbk2.google.com/cbk?output=tile&panoid=4fe6hEN9GJC6thoQBcgv0Q&zoom=4&x=11&y=2&cb_client=maps_sv
http://cbk1.google.com/cbk?output=tile&panoid=4fe6hEN9GJC6thoQBcgv0Q&zoom=4&x=10&y=2&cb_client=maps_sv
http://cbk0.google.com/cbk?output=tile&panoid=4fe6hEN9GJC6thoQBcgv0Q&zoom=4&x=9&y=2&cb_client=maps_sv
http://cbk3.google.com/cbk?output=tile&panoid=4fe6hEN9GJC6thoQBcgv0Q&zoom=4&x=8&y=2&cb_client=maps_sv
http://cbk2.google.com/cbk?output=tile&panoid=4fe6hEN9GJC6thoQBcgv0Q&zoom=4&x=10&y=3&cb_client=maps_sv
http://cbk1.google.com/cbk?output=tile&panoid=4fe6hEN9GJC6thoQBcgv0Q&zoom=4&x=9&y=3&cb_client=maps_sv
http://cbk3.google.com/cbk?output=tile&panoid=4fe6hEN9GJC6thoQBcgv0Q&zoom=4&x=11&y=3&cb_client=maps_sv
http://cbk2.google.com/cbk?output=tile&panoid=4fe6hEN9GJC6thoQBcgv0Q&zoom=4&x=9&y=4&cb_client=maps_sv
http://cbk1.google.com/cbk?output=tile&panoid=4fe6hEN9GJC6thoQBcgv0Q&zoom=4&x=8&y=4&cb_client=maps_sv
http://cbk0.google.com/cbk?output=tile&panoid=4fe6hEN9GJC6thoQBcgv0Q&zoom=4&x=8&y=3&cb_client=maps_sv
http://cbk0.google.com/cbk?output=tile&panoid=4fe6hEN9GJC6thoQBcgv0Q&zoom=4&x=11&y=4&cb_client=maps_sv
http://cbk3.google.com/cbk?output=tile&panoid=4fe6hEN9GJC6thoQBcgv0Q&zoom=4&x=10&y=4&cb_client=maps_sv
Mar 24, 2009 at 8:27 PM
Cool, I'm gonna try this!
Coordinator
Mar 25, 2009 at 8:38 PM
check http://gmap4dotnet.codeplex.com/SourceControl/changeset/view/32526#405090
Mar 26, 2009 at 6:15 PM
Edited Mar 26, 2009 at 6:46 PM
Wow, that looks nice! I've been busy also. Its VB and shows picture by picture, but it works :-)

Imports System.Net
Imports System.Xml
Imports System.IO

Public Class Form1

    Dim downer As New WebClient
    Dim PanoId As String = ""
    Dim x As Byte = 6
    Dim y As Byte = 3
    Dim zoom As Byte = 4
    Dim maxY As Byte = 0
    Dim maxX As Byte = 0
    Dim copyright As String = ""
    Dim lntlng As String = ""

#Region "Form"

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '//Verwijder oude meuk...
        If Not Directory.Exists("StreetView") Then Directory.CreateDirectory("StreetView")
        Dim dirInfo = My.Computer.FileSystem.GetDirectoryInfo("StreetView")
        Dim fileinfo As IO.FileInfo
        Dim dirInfo2 As IO.DirectoryInfo
        For Each dirInfo2 In dirInfo.GetDirectories()
            For Each fileinfo In dirInfo2.GetFiles()
                File.Delete(fileinfo.FullName)
            Next
        Next
        For Each fileinfo In dirInfo.GetFiles()
            File.Delete(fileinfo.FullName)
        Next

        '//Let's go!
        Randomize()
        GetAddress() '//Adres vragen...
        Dim m_xmld As XmlDocument
        Dim m_nodelist As XmlNodeList
        downer.Encoding = System.Text.Encoding.UTF8
        downer.Headers.Add(HttpRequestHeader.UserAgent, "P2000Monitor" & "/" & String.Format("Versie{0}", My.Application.Info.Version.ToString) & " (compatible; " & String.Format("{0}", My.Application.Info.Version.ToString) & "; " & GetOSVersion() & ")")
        m_xmld = New XmlDocument()

        Try
            m_xmld.InnerXml = downer.DownloadString("http://maps.google.com/cbk?output=xml&ll=" & lntlng)
            m_nodelist = m_xmld.SelectNodes("/panorama/data_properties/copyright")
            copyright = m_nodelist.Item(0).InnerText
            m_nodelist = m_xmld.SelectNodes("/panorama/annotation_properties")

            PanoId = m_nodelist(0).ChildNodes(0).Attributes(1).InnerText()

            DownloadImage()
        Catch
            MsgBox("Op deze locatie kan (nog) niet rondgekeken worden")
            Application.Exit()
        End Try
    End Sub

#End Region

#Region "DownloadImage"

    Private Sub DownloadImage()
        Dim newfile As String = "StreetView\img_" & x & "_" & y & "_" & zoom & ".jpg"
        If File.Exists(newfile) Then '//We hebben um al
            PictureBox1.ImageLocation = newfile
        Else '//Downloaden...
            downer.DownloadFile("http://cbk" & CInt(3 * New Random().NextDouble()) & ".google.com/cbk?output=tile&panoid=" & PanoId & "&zoom=" & zoom & "&x=" & (x Mod (maxX + 1)) & "&y=" & y & "&cb_client=maps_sv", newfile)
            PictureBox1.ImageLocation = newfile
        End If

        If y = 0 Then
            ButtonUp.Enabled = False
        Else
            ButtonUp.Enabled = True
        End If
        Select Case zoom
            Case 4
                maxY = 6
                maxX = 12
            Case 3
                maxY = 3
                maxX = 6
            Case 2
                maxY = 1
                maxX = 3
        End Select
        If y = maxY Then
            ButtonDown.Enabled = False
        Else
            ButtonDown.Enabled = True
        End If
    End Sub

#End Region

#Region "Buttons"

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonUp.Click
        y -= 1
        DownloadImage()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonDown.Click
        y += 1
        DownloadImage()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonLeft.Click
        If x - 1 < 0 Then
            x = maxX
        Else
            x -= 1
        End If
        DownloadImage()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonRight.Click
        x = (x + 1) Mod ((maxX * 2) + 1)
        DownloadImage()
    End Sub

#End Region

#Region "Hulpfuncties"

    Private Function GetOSVersion() As String
        Dim strVersion As String = ""
        Select Case Environment.OSVersion.Platform
            Case PlatformID.Win32Windows
                Select Case Environment.OSVersion.Version.Minor
                    Case 0
                        strVersion = "Windows 95"
                    Case 10
                        strVersion = "Windows 98"
                    Case 90
                        strVersion = "Windows ME"
                    Case Else
                        strVersion = ""
                End Select
            Case PlatformID.Win32NT
                Select Case Environment.OSVersion.Version.Major
                    Case 3 Or 4
                        strVersion = "Windows NT 4.0"
                    Case 5
                        Select Case Environment.OSVersion.Version.Minor
                            Case 0 '//Windowns 2000
                                strVersion = "Windows NT 5.0"
                            Case 1 '//Windows Xp
                                strVersion = "Windows NT 5.1"
                            Case 2 '//Windows 2003
                                strVersion = "Windows NT 5.2"
                        End Select
                    Case 6 '//Windows Vista
                        strVersion = "Windows NT 6.0"
                    Case Else
                        strVersion = ""
                End Select
            Case PlatformID.WinCE
                strVersion = "Windows CE"
        End Select
        Return strVersion
    End Function

    Private Function CalculateSize(ByVal text As String, ByVal font As Font) As Integer
        '//
        Dim g As Graphics = Me.CreateGraphics
        Return PictureBox1.Width - g.MeasureString(text, font).Width - 11
    End Function

    Private Sub GetAddress()
        Dim temptext() As String
        Dim tempaddress = InputBox("Waar wil je rondkijken?").Trim(" ")
        temptext = downer.DownloadString("http://maps.google.com/maps/geo?q=" & tempaddress & "&sensor=false&gl=nl&output=csv&key=ABQIAAAAifMAioXPImVgfQJNRYIKQBRkjPqkjI94V3Uzt92h9cU1lOsOdRSWBxjJj4xur8-xzYpAuYwVaxvtuQ").Split(",")
        If temptext(0) = 200 Then '//Geslaagde poging
            lntlng = temptext(2) & "," & temptext(3)
        ElseIf temptext(0) = 620 Then '//Teveel aanvragen, kappen voor n tijdje!
            MsgBox("Overbelast")
        End If
    End Sub

#End Region

#Region "PictureBox"

    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As Windows.Forms.MouseEventArgs) Handles PictureBox1.Click
        If e.Button = Windows.Forms.MouseButtons.Left Then
            If zoom + 1 < 5 Then
                zoom += 1
                x = x * 2
                If y > 0 Then y = Math.Floor(y * 2) - 1
                DownloadImage()
            End If
        ElseIf e.Button = Windows.Forms.MouseButtons.Right Then
            If zoom - 1 > 1 Then
                zoom -= 1
                x = x / 2
                y = Math.Ceiling(y / 2) - 1
                DownloadImage()
            End If
        End If
    End Sub

    Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
        Dim font As New System.Drawing.Font("Microsoft Sans Serif", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0)
        e.Graphics.DrawString(copyright, font, Brushes.Blue, CalculateSize(copyright, font), 463)
        e.Graphics.DrawString("Het adres is een benadering", font, Brushes.Blue, 0, 0)
    End Sub

#End Region

End Class

Coordinator
Mar 26, 2009 at 7:25 PM
nice, what about rotating 'inside' view?
Mar 26, 2009 at 7:31 PM
Well, that was my problem too. I'm going to think about it again... I think I should do something with matrixes or tiles or something like that, but I have zero experience in both.
Coordinator
Mar 26, 2009 at 9:06 PM
i think wpf should help us ;} 
Mar 29, 2009 at 8:11 PM
I found something:) I was searching for some more info, and found a Korean site with an example of an 360 degree rotation of a panorama picture. I can't read Korean, and the translation from Google Translate isn't readable, but the code is English commented here and there. It's on http://www.whatisthat.co.kr/?page=2 , around half of the page.
Coordinator
Mar 30, 2009 at 7:21 AM
check svn, some panorama is working now, thx!
Mar 30, 2009 at 11:16 AM
Wauw, it's very nice!
Coordinator
Apr 1, 2009 at 7:13 AM
some view ;}
Apr 2, 2009 at 8:20 PM
It's very nice. But what are you planning to do with it? It is now in "raw mode testing", but are you going to implement it into GMap, or..?.
Coordinator
Apr 3, 2009 at 5:40 AM
definitely in wpf version ;}
Apr 3, 2009 at 7:54 AM
oh,  :-(  but what about the majority of us using WinForms ???
Coordinator
Apr 3, 2009 at 9:35 AM
i wonder if it's even posible with gdi+
Apr 4, 2009 at 9:17 AM
Yeah.... I don't think so. But I read something about using WPF in WinForms. Is that possible?
Coordinator
Apr 4, 2009 at 1:09 PM
no need, just use wpf window
Aug 6, 2009 at 11:51 AM

i use ElementHost like this:

 

GMapControl1 = New System.Windows.Controls.GMapControl()
ElementHost1.Child = GMapControl1

just drag an ElementHost element into your windows form and set it's child like the above code.

(ElementHost control is located under "WPF Interoperability" in the toolbox)

Now that was easy :)

 

 

Aug 8, 2009 at 4:43 PM

I messed around with the StreetViewTest of RadioMan, modified some stuff, and tried your suggestion. But I get an error that says Window1 cannot be added to the Elementhost. It is a Dutch error, but translated it should be something like

"Window must be the root of the structure. Window can not be considered an underlying element of a Visual add."

I searched internet, but it has to be an UserControl to add it to the Elementhost, and it isn't. Problem is, I can't create a WPF UserControl with my Express Edition :'(

Any ideas?

Aug 9, 2009 at 11:49 AM

Fixed by creating a C# WPF project, removing Window1.xaml and App.xaml, adding a WPF Usercontrol and setting output-type to Class Library.

http://gmap4dotnet.codeplex.com/WorkItem/View.aspx?WorkItemId=13830 That's the result of it. I hope you can use it, I made quite some improvements.

Coordinator
Aug 9, 2009 at 4:14 PM

great, but as you see memory isue is still here, is it posible somehow to optimize it?

Aug 9, 2009 at 4:19 PM

I was thinking of that too, but I really have no idea how to fix that. Can't we only load the images visible at a particurlarly moment? So that if you turn the control it loads and unloads some images?

Coordinator
Aug 9, 2009 at 5:26 PM

how to UNload image in wpf? ;}

Aug 9, 2009 at 5:50 PM

I really don't have any idea, but I tried some stuff.

I commented "(buff.Children[buff.Children.Count - 1] as StackPanel).Children.Add(i);" But with zoom 4 memory was still 228MBs, and that was without a single image. (Well black images to render... But only 60MB smaller then normal.)

I also placed a breakpoint on "canvas.UpdateLayout();", at that point, it is already 108 MB. It get's at full size at "_RenderTargetBitmap.Render(buff);".

Conclusion: The memory does not really depends on the image quality, because without images it still uses a huge amount. Then the ram is invluenced by the canvassize and the StackPanel, which is getting smaller the lower the zoom is... Question is, how to lower the canvassize without showing half the street...

Coordinator
Aug 9, 2009 at 6:34 PM

quite not-trivial stuff... ;}

Aug 10, 2009 at 11:00 AM
Edited Aug 10, 2009 at 3:30 PM

I saved the total image (_RenderTargetBitmap) from my demoapp. Then I loaded it into the app of the Koreans, and that used "only" 150 MBs of ram instead of 370 for my demoapp. So what's the big diference between them?

[Edit]Used GC.Collect(); and GC.WaitForPendingFinalizers(); a bit more. Max 220 MBs right now.[/EDIT]

Coordinator
Aug 10, 2009 at 3:52 PM

hm...

Aug 10, 2009 at 7:01 PM

I tried the whole day now, but I can't get it any smaller. Irfanview tells me that the panorama image (Zoom 4) uses 65,3MB's of ram, the baseapp uses aprox. 50, so we *should* end up around 120. I think the PanoramaViewer class get's the rest, because I really don't know where the rest of the memory should be...

The 100Mb+ I got off, are used for the canvas, buff and _RenderTargetBitmap. It is still used, but just a few miliseconds after, it is cleared.

Any ideas?

 

Coordinator
Aug 10, 2009 at 7:47 PM

nop;