Street view not working in some places

Balasaheb Molawade 136 Reputation points
2023-01-09T12:35:38.577+00:00

Hi
We have used the Street view of Bing map V8 in our application. We used code from below link.
https://www.bing.com/api/maps/sdk/mapcontrol/isdk/setviewtostreetside
When user tried to get the street view for some places then its not showing street view. When we checked and found that its coming in Success call back function but not showing street view. In some places its going to error call back and we shown error message for this and its ok for us but issue with places where it come in successful call back and not showing street view or message so user got confuse.
Is any one face such type of issue and have solution for it.
Below is code.

   function showStreetViewOnIndMap(){  
                  //getting latitude and longitude  

     
     var streetViewLat = streetLatVal;  

     
           var streetViewLong = streetLongVal;  

     
           var bounds =   
   new Microsoft.Maps.LocationRect(new Microsoft.Maps.Location(streetViewLat, streetViewLong),  
   0.01,   
   0.01);  

     
           Microsoft.Maps.Map.getClosestPanorama(bounds, onSuccessOfStreetViewMap, onMissingCoverageOfStreetViewMap);  

     
   }  

     
   function onSuccessOfStreetViewMap(panoramaInfo) {  

     
           _map.setMapType(Microsoft.Maps.MapTypeId.streetside);  

     
           _map.setOptions({ panoramaInfo: panoramaInfo, zoom:   
   18 });  

     
   }  

     
   function onMissingCoverageOfStreetViewMap() {  
           alert("Street view is not found");  
   }  

Thanks!

Windows Maps
Windows Maps
A Microsoft app that provides voice navigation and turn-by-turn driving, transit, and walking directions.
253 questions
{count} votes

Accepted answer
  1. rbrundritt 16,471 Reputation points Microsoft Employee
    2023-01-17T16:22:06.17+00:00

    Looking into this I was surprised to find Streetview imagery in that location, but it is there. Looking through your code and doing some testing I found two issues:

    1. You are setting the map type to streetside before setting the location of the map. This causes the map to try and switch into streetview with the current map view which may not have streetview imagery.
    2. This is the bigger issue, you are passing in the panorama info directly in as a map option, it is actually an option of the streetsideOptions within the map options.

    Here is a quick fix for the onSuccessOfStreetViewMap function:

    function onSuccessOfStreetViewMap(panoramaInfo) {  
       map.setOptions({ streetsideOptions: { panoramaInfo: panoramaInfo}, zoom:    18 }); 
       map.setMapType(Microsoft.Maps.MapTypeId.streetside);  	   
    }  
    
    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. IoTGirl 3,051 Reputation points Microsoft Employee
    2023-01-18T00:08:33.3366667+00:00

    Hi Balasaheb,

    The fail over sample is a little further down in the iSDK at Streetside Failover to Road.

    Sincerely, IoTGirl

    0 comments No comments