Android Code Snippet [B4X] Google Street View Get Picture

Discussion in 'Code Snippets' started by Alexander Stolte, Feb 1, 2018.

  1. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

    With this Code you can get the picture of a Google Street View Position. Here you can check if is available.

    Code:
    Sub getStreetViewPicture(width As Int, height As Int ,lat As Float, lon As Float)
       
        
    Dim j As HttpJob
        j.Initialize(
    "", Me)
        j.Download(
    "https://maps.googleapis.com/maps/api/streetview?size=" & width & "x" & height & "&location=" & lat & "," & lon)

        
    Wait For (j) JobDone(j As HttpJob)
        
    If j.Success Then
           
        myImageView.Bitmap = j.GetBitmap
           
        
    End If
       
        j.Release
       
    End Sub

    Have Fun with a new feature!
     
    Last edited: Feb 1, 2018
    stanks likes this.
  2. DonManfred

    DonManfred Expert Licensed User

    This is compatible with B4A/B4J and B4I?
     
  3. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

    Yes, i write this for example in B4J. It is a simple HTTP Job.
     
  4. DonManfred

    DonManfred Expert Licensed User

    works in B4A and B4I but not in B4J.

    In B4J it must be
    Code:
    'Good example. Use.
    Sub DownloadImage(Link As String, iv As ImageView)
       
    Dim job As HttpJob
       job.Initialize(
    "", Me) 'note that the name parameter is no longer needed.
       job.Download(Link)
       
    Wait For (job) JobDone(job As HttpJob)
       
    If job.Success Then
         iv.SetImage (job.GetBitmap) 
    'replace with iv.Bitmap = job.GetBitmap in B4A / B4i
       End If
       job.Release
    End Sub
     
    Alexander Stolte likes this.
  5. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

    True, I probably had my head full. Thanks.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice