Note that there are some explanatory texts on larger screens.

plurals
  1. POjavascript global variable question
    primarykey
    data
    text
    <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"&gt; &lt;head&gt; &lt;meta http-equiv="content-type" content="text/html; charset=utf-8"/&gt; &lt;title&gt;Google Maps JavaScript API Example: Simple Streetview Example&lt;/title&gt; &lt;script src="http://maps.google.com/maps?file=api&amp;amp;v=2.x&amp;amp;key=&lt;?=APIKEY?&gt;" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; var myPano; var newPoint; function initialize() { var fenwayPark = new GLatLng(42.345573,-71.098326); var address = "1600 Amphitheatre Parkway, Mountain View, CA, USA"; var geocoder = new GClientGeocoder(); geocoder.getLatLng( address, function(point) { if (!point) { alert(address + " not found"); } else { newPoint = point; alert("inside of function: " + newPoint); } }); alert("outside of function: " + newPoint); panoramaOptions = { latlng:fenwayPark }; myPano = new GStreetviewPanorama(document.getElementById("pano"), panoramaOptions); GEvent.addListener(myPano, "error", handleNoFlash); } function handleNoFlash(errorCode) { if (errorCode == FLASH_UNAVAILABLE) { alert("Error: Flash doesn't appear to be supported by your browser"); return; } } &lt;/script&gt; </code></pre> <p></p> <p> </p> <p>when I run this code, the alert("outside of function: " + newPoint); have not got any value, but in the function alert("inside of function: " + newPoint); it gets.</p> <p>complete code:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"&gt; &lt;head&gt; &lt;meta http-equiv="content-type" content="text/html; charset=utf-8"/&gt; &lt;title&gt;Google Maps JavaScript API Example: Simple Streetview Example&lt;/title&gt; &lt;script src="http://maps.google.com/maps?file=api&amp;amp;v=2.x&amp;amp;key=ABQIAAAAgVzm2syhpm0A5rAKFMg3FBS-DTtkk0JB-Y_gKL-3MRZwBHch9RSjWJj17-fEEecjCvYeo1i7w_1yPw" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; var myPano; function initialize() { var geocoder = new GClientGeocoder(); var address = "1600 Amphitheatre Parkway, Mountain View, CA, USA"; geocoder.getLatLng( address, function(point) { if (!point) { alert(address + " not found"); } else { panoramaOptions = { latlng:point }; myPano = new GStreetviewPanorama(document.getElementById("pano"), panoramaOptions); GEvent.addListener(myPano, "error", handleNoFlash); } }); } function handleNoFlash(errorCode) { if (errorCode == FLASH_UNAVAILABLE) { alert("Error: Flash doesn't appear to be supported by your browser"); return; } } &lt;/script&gt; </code></pre> <p></p> <p> </p> <p>I want to show the street view of address:1600 Amphitheatre Parkway, Mountain View, CA, USA when opening the page</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload