cesium Streetview

1675 단어 streetviewCesium
개요
cesium로streeview를 연결해 보았습니다.
사진.

샘플 코드
var viewer = new Cesium.Viewer('cmap');
var panorama;
viewer.canvas.addEventListener('click', function(e) {
    var mousePosition = new Cesium.Cartesian2(e.clientX, e.clientY); 
    var ellipsoid = viewer.scene.globe.ellipsoid;
    var cartesian = viewer.camera.pickEllipsoid(mousePosition, ellipsoid);
    if (cartesian) 
    {
        var cartographic = ellipsoid.cartesianToCartographic(cartesian);
        var lon = Cesium.Math.toDegrees(cartographic.longitude).toFixed(6);
        var lat = Cesium.Math.toDegrees(cartographic.latitude).toFixed(6); 
        pano(lat, lon);
    }
    else
    {
        alert('Globe was not picked');
    }   
}, false);
viewer.camera.flyTo({
    destination: Cesium.Cartesian3.fromDegrees(139.60, 35.60, 10000.0),
});
function pano(lat, lon) {
    var koko = new google.maps.LatLng(lat, lon);
    var sv = new google.maps.StreetViewService();
    panorama = new google.maps.StreetViewPanorama(document.getElementById('gmap'));
    sv.getPanoramaByLocation(koko, 50, processSVData);
}
function processSVData(data, status) {
    if (status == google.maps.StreetViewStatus.OK)
    {
        panorama.setPano(data.location.pano);
        panorama.setPov({
            heading: 270,
            pitch: 0,
            zoom: 1
        });
        panorama.setVisible(true);
    }
    else 
    {
        alert("この場所はストリートビューのデータがありません");
    }
}


성과물
이상.

좋은 웹페이지 즐겨찾기