0

我使用了以下 URL 中的示例代码。 http://earth-api-samples.googlecode.com/svn/trunk/examples/geocoder.html

我想在页面加载后显示位置。我是谷歌地球的新手。

现在,我已经删除了位置表单,并在 initCB 方法下调用了 buttonClick 函数。它没有用。

请帮忙。

4

1 回答 1

0

您必须将城市传递给代码中的地理编码器,或者获取之前的纬度/经度并将其插入代码中。

-1。第一个选项

该示例使用 Google Maps v.2 API,而现在您可以在此处使用 v.3:https ://developers.google.com/maps/documentation/javascript/geocoding

var address = "Los Angeles";
geocoder.geocode( { 'address': address}, function(results, status) {
  if (status == google.maps.GeocoderStatus.OK) {
    point = results[0].geometry.location;
    alert(point);//this is to see the lat long values
    var lookAt = ge.createLookAt('');
    lookAt.set(point.y, point.x, 10, ge.ALTITUDE_RELATIVE_TO_GROUND, 
           0, 60, 20000);
ge.getView().setAbstractView(lookAt);

  } else {
    alert("Geocode was not successful for the following reason: " + status);
  }

-2。第二种选择

var lookAt = ge.createLookAt('');
lookAt.set(50.5, -79.5, 10, ge.ALTITUDE_RELATIVE_TO_GROUND, 
           0, 60, 20000);
ge.getView().setAbstractView(lookAt);

其中 50.5 应该是纬度,-79.5 应该是经度。

希望能帮助到你!

干杯,米海

于 2013-09-09T05:28:51.663 回答