detecting “we have no imagery” of google maps street view static images

后端 未结 6 1705
梦毁少年i
梦毁少年i 2021-02-13 17:43

I\'m generating street view static images like so:

https://maps.googleapis.com/maps/api/streetview?size=1080x400&location=%s&fov=90&heading=235&pitch=0&a

6条回答
  •  执笔经年
    2021-02-13 18:47

    this situation is already build in in the 3.0 version due the boolean test status === streetviewStatus.Ok, here is a snippet from my situation solving

    if (status === google.maps.StreetViewStatus.OK) {
                var img = document.createElement("IMG");
                img.src = 'http://maps.googleapis.com/maps/api/streetview?size=160x205&location='+ lat +','+ lng  +'&sensor=false&key=AIzaSyC_OXsfB8-03ZXcslwOiN9EXSLZgwRy94s';
                var oldImg = document.getElementById('streetViewImage');
                document.getElementById('streetViewContainerShow').replaceChild(img, streetViewImage);
            } else {
                var img = document.createElement("IMG");
                img.src = '../../images/ProfilnoProfilPicture.jpg';
                img.height = 205;
                img.width = 160;
                var oldImg = document.getElementById('streetViewImage');
                document.getElementById('streetViewContainerShow').replaceChild(img, streetViewImage);
            }
    

提交回复
热议问题