I used code from this Stack Overflow Thread, thank you very much. And I used the Streetview code from Google Javascript Maps API below that. However, I get nothing back. The alert(latitude) works and alert(longitude) works. But down below when I try to display the Street View it says, "Uncaught ReferenceError: latitude is not defined". I tried pasting the values returned in the alerts into the StreetView code and then the DIV turned grey. Stumped I am.
<div id="map" style="border-width:medium;border-style:solid; border-color:Red;width:200px;height:150px;"></div>
<script type="text/javascript">
function initMap(){
var geocoder = new google.maps.Geocoder();
var address = "new york";
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
alert(latitude);
alert(longitude);
}
});
var panorama;
panorama = new google.maps.StreetViewPanorama(
document.getElementById('map'),
{
position: { lat: latitude, lng: longitude },
pov: { heading: 165, pitch: 0 },
zoom: 1
});
}
</script>