Dim Intent1 As Intent
Dim Uri As String
Uri="google.streetview:cbll="&ALatitude&","&ALongitude
Intent1.Initialize(Intent1.ACTION_VIEW, Uri)
StartActivity(Intent1)
var map;
var berkeley = new google.maps.LatLng(37.869085,-122.254775);
var sv = new google.maps.StreetViewService();
var panorama;
function initialize() {
panorama = new google.maps.StreetViewPanorama(document.getElementById("pano"));
// Set up the map
var mapOptions = {
center: berkeley,
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP,
streetViewControl: false
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
// getPanoramaByLocation will return the nearest pano when the
// given radius is 50 meters or less.
google.maps.event.addListener(map, 'click', function(event) {
sv.getPanoramaByLocation(event.latLng, 50, processSVData);
});
}
function processSVData(data, status) {
if (status == google.maps.StreetViewStatus.OK) {
var marker = new google.maps.Marker({
position: data.location.latLng,
map: map,
title: data.location.description
});
google.maps.event.addListener(marker, 'click', function() {
var markerPanoID = data.location.pano;
// Set the Pano to use the passed panoID
panorama.setPano(markerPanoID);
panorama.setPov({
heading: 270,
pitch: 0
});
panorama.setVisible(true);
});
}
}
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="https://maps.googleapis.com/maps/api/js?sensor=true"></script>
<script>
function checkStreetView(latitude, longitude, meters){
streetViewService.getPanoramaByLocation(new google.maps.LatLng(latitude, longitude), meters, function(data, status){
var streetViewAvailable;
if (status==google.maps.StreetViewStatus.OK) {
streetViewAvailable=true;
} else {
streetViewAvailable=false;
}
B4A.CallSub('StreetViewChecked', true, streetViewAvailable.toString());
});
}
function initialize(){
streetViewService = new google.maps.StreetViewService();
B4A.CallSub('StreetViewCheckerInitialized', true);
}
var streetViewService;
</script>
</head>
<body onload="initialize()">
</body>
</html>
Sub Process_Globals
End Sub
Sub Globals
Dim StreetViewCheckerIsInitialized As Boolean=False
Dim WebViewExtras1 As WebViewExtras
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim WebView1 As WebView
WebView1.Initialize("WebView1")
WebViewExtras1.Initialize(WebView1)
' seems to work with no need to add the WebView to the Activity
' Activity.AddView(WebViewExtras1, 0, 0, 100%x, 100%y)
Dim JavascriptInterface1 As DefaultJavascriptInterface
JavascriptInterface1.Initialize
WebViewExtras1.AddJavascriptInterface(JavascriptInterface1, "B4A")
WebViewExtras1.LoadUrl("file:///android_asset/streetview_checker.html")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub StreetViewCheck(Latitude As Double, Longitude As Double, Meters As Int)
If StreetViewCheckerIsInitialized Then
Dim Javascript As StringBuilder
Javascript.Initialize
Javascript.Append("javascript:checkStreetView(")
Javascript.Append(Latitude)
Javascript.Append(",")
Javascript.Append(Longitude)
Javascript.Append(",")
Javascript.Append(Meters)
Javascript.Append(");")
Log("StreetViewCheck: "&Javascript.ToString)
WebViewExtras1.ExecuteJavascript(Javascript.ToString)
' now waiting for the StreetViewChecked Sub to be called by the webpage javascript
Else
Log("The StreetViewChecker is not yet initialized")
End If
End Sub
Sub StreetViewChecked(Available As String)
' this Sub is called by the webpage javascript once it has received the result of it's getPanoramaByLocation request
' Available will be a String 'true' or 'false'
' (the webpage javascript can only pass String values to B4A, it cannot pass a Boolean)
Log("StreetViewChecked result is "&Available)
End Sub
Sub StreetViewCheckerInitialized
' this Sub is called by the webpage javascript once it has initialized itself
' if an error occurs this Sub will not get called so some sort of error trapping ought to be implemented
Log("StreetViewCheckerInitialized")
StreetViewCheckerIsInitialized=True
' StreetViewCheck(52.77132, 0.38332, 10) ' i know there's no StreetView available here
StreetViewCheck(52.75424, 0.40267, 50) ' i know there is StreetView available here
End Sub
getPanoramaByLocation() searches for panorama data over a given area, given a passed LatLng and the radius (in meters) over which to search.
If the radius is 50 meters or less, the panorama returned will be the nearest panorama to the given location.
StreetViewCheck(48.203718,16.361456, 10)
warwound, please put again webviewextras2.