Click here to Skip to main content
15,064,093 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a problem when maping with the google earth.,i want submit the laitude and longituede. then mapping the location on google earth . here are my codes;

JavaScript
<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>
Posted
Updated 7-Nov-13 19:31pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900