2016-06-14 10 views

答えて

0

の場所を得ることはありませんので、それは(強調鉱山)、人のIPアドレスで動作します:

は直接あなたがプログラムでストリートビューのデータの可用性を判断したい、またはマップ/パノラマの直接操作を必要とせずに、特定のパノラマについての情報を返すことが

ストリートビューのデータへのアクセス。 Googleのストリートビューサービスに保存されているデータへのインターフェイスを提供するStreetViewServiceオブジェクトを使用すると、そうすることができます。

あなたはStreetViewServiceに2つのタイプの要求を開始することができる:StreetViewLocationRequestと

<snip>

  • 要求はこれが渡された緯度経度与えられた所定の領域の上にパノラマデータ、検索します。

コードスニペット(this example in the documentationからコピーし、最寄りのストリートビューパノラマを返すために、地図上をクリック)

/* 
 
* Click the map to set a new location for the Street View camera. 
 
*/ 
 
var map; 
 
var panorama; 
 

 
function initMap() { 
 
    var berkeley = { 
 
    lat: 37.869085, 
 
    lng: -122.254775 
 
    }; 
 
    var sv = new google.maps.StreetViewService(); 
 
    panorama = new google.maps.StreetViewPanorama(document.getElementById('pano')); 
 
    // Set up the map. 
 
    map = new google.maps.Map(document.getElementById('map'), { 
 
    center: berkeley, 
 
    zoom: 16, 
 
    streetViewControl: false 
 
    }); 
 
    // Set the initial Street View camera to the center of the map 
 
    sv.getPanorama({ 
 
    location: berkeley, 
 
    radius: 50 
 
    }, processSVData); 
 
    // Look for a nearby Street View panorama when the map is clicked. 
 
    // getPanoramaByLocation will return the nearest pano when the 
 
    // given radius is 50 meters or less. 
 
    map.addListener('click', function(event) { 
 
    sv.getPanorama({ 
 
     location: event.latLng, 
 
     radius: 50 
 
    }, processSVData); 
 
    }); 
 
} 
 

 
function processSVData(data, status) { 
 
    if (status === google.maps.StreetViewStatus.OK) { 
 
    var marker = new google.maps.Marker({ 
 
     position: data.location.latLng, 
 
     map: map, 
 
     title: data.location.description 
 
    }); 
 
    panorama.setPano(data.location.pano); 
 
    panorama.setPov({ 
 
     heading: 270, 
 
     pitch: 0 
 
    }); 
 
    panorama.setVisible(true); 
 
    marker.addListener('click', function() { 
 
     var markerPanoID = data.location.pano; 
 
     // Set the Pano to use the passed panoID. 
 
     panorama.setPano(markerPanoID); 
 
     panorama.setPov({ 
 
     heading: 270, 
 
     pitch: 0 
 
     }); 
 
     panorama.setVisible(true); 
 
    }); 
 
    } else { 
 
    console.error('Street View data not found for this location.'); 
 
    } 
 
}
html, 
 
body { 
 
    height: 100%; 
 
    margin: 0; 
 
    padding: 0; 
 
} 
 
#map { 
 
    height: 100%; 
 
}
<div id="map" style="width: 45%; height: 100%;float:left"></div> 
 
<div id="pano" style="width: 45%; height: 100%;float:left"></div> 
 
<!-- Replace the value of the key parameter with your own API key. --> 
 
<script async defer src="https://maps.googleapis.com/maps/api/js?callback=initMap"></script>

+0

あなたの答えをいただき、ありがとうございます。それは私を助けます。再度、感謝します。 – RomangRider

関連する問題