<html> <head> <title>Sample</title> <script type="text/javascript" src="https://www.google.com/jsapi"> </script> <script type="text/javascript"> var ge; var x=38; var y=116; google.load("earth", "1"); function init() { google.earth.createInstance('map3d', initCB, failureCB); } function initCB(instance) { ge = instance; ge.getWindow().setVisibility(true); ge.getNavigationControl().setVisibility(ge.VISIBILITY_SHOW); } function locate(){ x=document.getElementById("latitude").value; y=document.getElementById("longitude").value; alert(x); alert(y); var lookAt = ge.createLookAt(''); // Set the position values. lookAt.setLatitude(x); lookAt.setLongitude(y); lookAt.setRange(100.0); //default is 0.0 // Update the view in Google Earth. ge.getView().setAbstractView(lookAt); } function failureCB(errorCode) { } google.setOnLoadCallback(init); </script> </head> <body> <input value=36 id="latitude" />经度 <input value=118 id="longitude" />纬度 <input type="button" onclick="locate()"> <div id="map3d" style="height: 600px; width: 800px;"></div> </body> </html>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)