Android Code Snippet [B4X] Check if Google Street View is available

This code check's easy and fast if Google Street View is available.

You need the latitude and longitude. You can here get a API Key. Here you can more read about this.

B4X:
Sub isStreetViewAvailable(lat As Float, lon As Float)
    
    Dim j As HttpJob
    j.Initialize("", Me)
    j.Download("https://maps.googleapis.com/maps/api/streetview/metadata?location=" & lat & "," & lon & "&key=" & STREET_API)
    
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        
        Dim jp As JSONParser
        jp.Initialize(j.GetString)
        
        Dim status As String = jp.NextObject.GetDefault("status", 0)
    
        If  status.Contains("OK") Then
            
            Log("Streetview is available!")
        
        Else
        
            Log("Streetview is not available!")
        
        End If
    
    End If
    j.Release

End Sub

Have Fun with a new Feature!
 
Top