Using image from street view

坚强是说给别人听的谎言 提交于 2019-12-01 14:09:33

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,

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!