开发者

How to get GPOINT by City in Google Maps API Javascript

开发者 https://www.devze.com 2023-03-13 14:56 出处:网络
I have the string - \"Moscow\". How to get a Gpoint (coords) from the my string? I n开发者_StackOverfloweed result about : new GPoint(30.3112,59.99322);Well, v2 API says that GPoint does not represe

I have the string - "Moscow".

How to get a Gpoint (coords) from the my string?

I n开发者_StackOverfloweed result about : new GPoint(30.3112,59.99322);


Well, v2 API says that GPoint does not represent a point on Earth by geographical coordinates but GLatLng does.

To get coordinates you need to use 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
    }
});


The Google Geocoding API will do the job for you, description and examples here: http://code.google.com/apis/maps/documentation/geocoding/

0

精彩评论

暂无评论...
验证码 换一张
取 消