【问题标题】:Google Earth: How to show a location in google earth after the page loads谷歌地球:页面加载后如何在谷歌地球中显示位置
【发布时间】:2013-09-09 13:28:51
【问题描述】:

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

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

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

请帮忙。

【问题讨论】:

    标签: google-maps google-earth


    【解决方案1】:

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

    -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 应该是经度。

    希望对你有帮助!

    干杯, 米海

    【讨论】:

      猜你喜欢
      • 2014-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-12
      • 1970-01-01
      相关资源
      最近更新 更多