Question

I want to get a picture of streetview (stating latitude and longitude) and display in a dialog, is this possible?

I saw some examples here, but not found one that show me how to display the image in dialog.

Sorry if already exists this question in the site, but I not found when I search.

Was it helpful?

Solution

Yes you can,

as a URL root you can use this one http://cbk0.google.com/ or maps.google.com

and this is a example where you use above mentioned URL by providing location:

http://cbk0.google.com/cbk?output=xml&hl=x-local&ll=34.058593,-118.240673&it=all

The result should be:

  <panorama>
     <data_properties image_width="13312" image_height="6656" tile_width="512" tile_height="512" pano_id="70o9Pukc2KSjO-PfeHussw" scene="1" imagery_type="2" level_id="ffffffffb3840000" num_zoom_levels="5" lat="34.058620" lng="-118.240693" original_lat="34.058620" original_lng="-118.240693" best_view_direction_deg="109.819">
    <copyright>© 2013 Google</copyright>
      <text/>
     <street_range/>
      <region/>
      <country/>
    </data_properties>
<projection_properties projection_type="spherical" pano_yaw_deg="93.25" tilt_yaw_deg="-180" tilt_pitch_deg="0"/>
<annotation_properties>
   <link yaw_deg="252.58" pano_id="qciD6ogWmkxiq4p3OaprjA" road_argb="0x80fdf872" scene="1">
      <link_text/>
    </link>
     <link yaw_deg="38.52" pano_id="lqiWuIrIXa_86In3RRxB1w" road_argb="0x80fdf872" scene="1">
     <link_text/>
     </link>
</annotation_properties>
    <levels>
   <level level_id="ffffffffb3840000" pano_id="70o9Pukc2KSjO-PfeHussw" ordinal="0">
    <text/>
    <abbreviation/>
   </level>
    </levels>
</panorama> 

From XML you fetch pano_id, (in my case pano_id="70o9Pukc2KSjO-PfeHussw")

and after you can extract image based on pano_id:

http://cbk0.google.com/cbk?output=tile&panoid=70o9Pukc2KSjO-PfeHussw&zoom=3&x=5&y=1

Other way to get XML from maps.google.com:

http://maps.google.com/cbk?output=xml&ll=32.051626,34.7613

to load Image from URL, there is a lot options:

Drawable

public static Drawable LoadImageFromWebOperations(String url) {
try {
    InputStream is = (InputStream) new URL(url).getContent();
    Drawable d = Drawable.createFromStream(is, "src name");
    return d;
} catch (Exception e) {
    return null;
 }
}

or to Bitmap:

 try {
  ImageView i = (ImageView)findViewById(R.id.image);
   Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new URL(imageUrl).getContent());
   i.setImageBitmap(bitmap); 
  } catch (MalformedURLException e) {
    e.printStackTrace();
  } catch (IOException e) {
    e.printStackTrace();
  }

Hope it will help you,

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top