Kirill Firsov
Kirill Firsov

Reputation: 519

How to get GPOINT by City in Google Maps API Javascript

I have the string - "Moscow".

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

I need result about : new GPoint(30.3112,59.99322);

Upvotes: 1

Views: 1588

Answers (2)

Aston
Aston

Reputation: 3712

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

Upvotes: 0

Yuri Stuken
Yuri Stuken

Reputation: 13590

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
    }
});

Upvotes: 2

Related Questions