コンピュータや音楽の事書いてます

Google - Code Playground - 試してみた

ページ左側からサンプルを選ぶとGoogle AJAX APIを使った色んなコード例が出てきて、その場で編集も実行も出来る。
http://code.google.com/apis/ajax/playground/

試しにこれを
http://code.google.com/apis/ajax/playground/#map_streetview_object
この様に編集してみると、

function initialize() {
  var myPano = new GStreetviewPanorama(document.getElementById("pano"));
  fenwayPark = new GLatLng(35.658822,139.745418);
  myPOV = {yaw:200,pitch:-40};
  myPano.setLocationAndPOV(fenwayPark, myPOV);
  GEvent.addListener(myPano, "error", handleNoFlash);
}

function handleNoFlash(errorCode) {
  if (errorCode == 603) {
    alert("Error: Flash doesn't appear to be supported by your browser");
    return;
  }
}

お見事。
どんだけ親切なんだろうか・・・・

おまけ:単体で動かすなら(エラー処理とか省いてある)

<script src="http://maps.google.com/maps?file=api"></script> 
<script> 
function initialize() {
	var myPano = new GStreetviewPanorama(document.getElementById("pano"));
	myPano.setLocationAndPOV(new GLatLng(35.658822,139.745418), {yaw:200,pitch:-40});
}
</script> 
<body onload="initialize()" onunload="GUnload()" style="font-family: Arial;border: 0 none;"> <div name="pano" id="pano" style="width: 800px; height: 800px"></div> 
</body>