我的街景警报框未能显示

时间:2015-03-18 18:17:54

标签: javascript android google-maps google-maps-api-3

正在开发一个使用街道全景的Android应用程序,我尝试在加载街景之前从某个位置查询街景的可用性,但它不起作用。如果我键入一个有效的街景位置,它将加载,但是当我键入一个无效的位置时,它将无法显示警告消息,告诉用户该街道不可用。这是下面的代码。

  function codeAddress() {


    var address = document.getElementById('autocomplete').value;
    geocoder.geocode( { 'address': address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {

       map.setCenter(results[0].geometry.location);

      var streetViewService = new google.maps.StreetViewService();
      var STREETVIEW_MAX_DISTANCE = 100;

       streetViewService.getPanoramaByLocation(results[0].geometry.location, STREETVIEW_MAX_DISTANCE, function (streetViewPanoramaData, status) {

              if (status === google.maps.StreetViewStatus.OK) {
               panorama.setPosition(results[0].geometry.location);
                  }
              else {
                alert("Street view not available in your location");
                 }
            });
         }

     else {
      alert('Geocode was not successful for the following reason: ' + status);
               }
          });
        }

0 个答案:

没有答案