google earth 3d开发的问题的小问题

simple6686 2013-11-08 02:06:14
哪位大侠帮帮忙啊我想实现Google earth 输入经纬度定位的功能
<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>
...全文
147 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

87,991

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧