Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Thanks a bunch Alos and steemcb, I was stuck with street view showing the wrong property or a blank screen. I hope google comes out with a native android SDK, until then both your codes ROX!!</p> <p>I had to make a few adjustments before I could use the code. Here is my implementation.</p> <p>strings.xml</p> <pre><code>&lt;string formatted="false" name="html_streetview"&gt; &amp;lt;html&gt; &amp;lt;head&gt; &amp;lt;script src=\"http://maps.google.com/maps?file=api&amp;amp;amp;v=2&amp;amp;amp;sensor=false\" type=\"text/javascript\"/&gt; &amp;lt;/head&gt; &amp;lt;body&gt; &amp;lt;script type=\"text/javascript\"&gt; var testPoint = new GLatLng(%1$s, %2$s); var svClient = new GStreetviewClient(); svClient.getNearestPanoramaLatLng(testPoint,function(camera){ if (camera !== null){ lat2 = camera.lat(); lon2 = camera.lng(); lat1 = testPoint.lat(); lon1 = testPoint.lng(); dLon = lon1 - lon2; y = Math.sin(dLon) * Math.cos(lat2); x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLon); var bearing = Math.atan2(y, x) * (180 / Math.PI); //had to get rid of this line it was causing formatting exceptions // I moved this logic to the inner class //bearing = (bearing + 180) % 360; Android.setStreetViewAngle(bearing); } //had trouble with bearing taking long to calculate and end up with 0.0 value in the uri. So I put it in here after when bearing is calculated. Not pretty.. but it works for me svClient.getNearestPanoramaLatLng(testPoint, function (nearest) { if ((nearest !== null) &amp;amp;&amp;amp; (testPoint.distanceFrom(nearest) &amp;lt;= 100)) { Android.hasStreetview(true); } else { Android.hasStreetview(false); } }); }); &amp;lt;/script&gt; &amp;lt;/body&gt; &amp;lt;/html&gt; &lt;/string&gt; </code></pre> <p>Private Inner Class</p> <pre><code> private final Context context; private double bearing; public JavascriptCheck(Context context) { this.context = context; } public void hasStreetview(boolean hasStreetview) { if (hasStreetview) { String uri = "google.streetview:cbll=" + propDetailInfo.getLatitude() + "," + propDetailInfo.getLongitude() + "&amp;cbp=1,"+ bearing + ",,1,1.0&amp;mz=14"; Utils.printDebug("URI: " + uri); Intent streetView = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); startActivity(streetView); } else { Toast.makeText(context, "Sorry Streetview not available for this address", Toast.LENGTH_LONG).show(); } } public void setStreetViewAngle(double bearing){ bearing = (bearing + 180) % 360; this.bearing = bearing; } public void toast(String part) { Toast.makeText(context, part, Toast.LENGTH_SHORT).show(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload