2014-07-15 81 views

回答

0

可能是下面的代碼,將有助於你:

<!DOCTYPE html> 
<html> 
    <head> 
    <meta charset="utf-8"> 
    <title>Street View service</title> 
    <style> 
     html, body, #map-canvas { 
     height: 100%; 
     margin: 0px; 
     padding: 0px 
     } 
    </style> 
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script> 
    <script> 
function initialize() { 
    var fenway = new google.maps.LatLng(42.345573, -71.098326); 
    var mapOptions = { 
    center: fenway, 
    zoom: 14 
    }; 
    var map = new google.maps.Map(
     document.getElementById('map-canvas'), mapOptions); 
    var panoramaOptions = { 
    position: fenway, 
    pov: { 
     heading: 34, 
     pitch: 10 
    } 
    }; 
    var panorama = new google.maps.StreetViewPanorama(document.getElementById('pano'), panoramaOptions); 
    map.setStreetView(panorama); 
} 

google.maps.event.addDomListener(window, 'load', initialize); 

    </script> 
    </head> 
    <body> 
    <div id="map-canvas" style="width: 400px; height: 300px"></div> 
    <div id="pano" style="position:absolute; left:410px; top: 8px; width: 400px; height: 300px;"></div> 
    </body> 
</html> 
+0

這幾乎可行。但那只是設置街景。我需要專門設置pegman。 –

+0

是的,在第一個div中,你可以看到pegman根據提供的位置(位置)進行定位.... – Mayank

+0

有沒有辦法在js中完成它? –

0

優於從不遲到,但你正在尋找的全景功能setPosition

setStreetView設置全景視圖,但應該的setPosition放置pegman。