【问题标题】:How to get GPOINT by City in Google Maps API Javascript如何在 Google Maps API Javascript 中按城市获取 GPOINT
【发布时间】:2011-06-16 10:42:01
【问题描述】:

我有字符串 - “莫斯科”。

如何从我的字符串中获取 Gpoint(坐标)?

我需要结果:new GPoint(30.3112,59.99322);

【问题讨论】:

  • 您使用的是什么 API 版本?
  • @Yuri v2 可以从类名GPoint 推导出来 - v3 使用google.maps. 命名空间

标签: javascript google-maps google-maps-api-2


【解决方案1】:

好吧,v2 API 说 GPoint does not represent 是地球上地理坐标的一个点,但 GLatLng 确实如此。

要获取坐标,您需要使用geocoding:

geocoder = new GClientGeocoder();
geocoder.getLatLng("Moscow", function(point)
{
    if (point == null)
    {
        // nothing found
    }
    else
    {
        // point is an instance of GLatLng with coordinates you need
    }
});

【讨论】:

    【解决方案2】:

    Google 地理编码 API 将为您完成这项工作,这里有描述和示例: http://code.google.com/apis/maps/documentation/geocoding/

    【讨论】:

      猜你喜欢
      • 2018-07-25
      • 2012-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-08
      • 2023-04-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多