Search code examples
google-mapsgoogle-street-view

Google street view API parameters to change range


Google street view API

URL: https://maps.googleapis.com/maps/api/streetview?size=600x600&location=46.2277933992467,9.04836208165778&key=myapikey

Result: "sorry we have no imagery here"

I am looking for a specific parameter to change this "range".

Example: with "no imagery here" range is 10 meters ---> i need 50 meteres, so i will get an image.

Help me please

Thank you


Solution

  • Currently, you cannot find existing panorama in "range" using Google Maps Street View API or Metadata. There is a feature request in Google issue tracker to add a radius parameter in these APIs:

    https://issuetracker.google.com/issues/35830450

    Feel free to star this feature request to express your interest.

    The workaround might be searching a pano ID using Google Maps JavaScript API as shown in this answer:

    https://stackoverflow.com/a/45282758/5140781

    UPDATE

    Good news. Google implemented feature request 35830450 and added radius parameter in Street View Image API.

    radius (default is 50) sets a radius, specified in meters, in which to search for a panorama, centered on the given latitude and longitude. Valid values are non-negative integers.

    source: https://developers.google.com/maps/documentation/streetview/intro

    For your example I figured out that setting radius to 60 meters will return panorama.

    Metadata request https://maps.googleapis.com/maps/api/streetview/metadata?location=46.2277933992467%2C9.04836208165778&radius=60&key=MY_API_KEY returns

    {
        "copyright":"© Google, Inc.",
        "date":"2014-11",
        "location":{
            "lat":46.22730779489779,
            "lng":9.048190155237283
        },
        "pano_id":"xB0bwJka4pfLk6hLri-t_w",
        "status":"OK"
    }
    

    Have a look at code snippet

    <img src="https://maps.googleapis.com/maps/api/streetview?location=46.2277933992467%2C9.04836208165778&size=600x400&radius=60&key=AIzaSyDztlrk_3CnzGHo7CFvLFqE_2bUKEq1JEU&signature=s7tfGqXSJ3csbFmE91-AXMieFfg=">