开发者

"Google Map" how can we get Lattitude and Longitude by passing the Address

In Google Maps how can we get Latitude and Longitude by passing the Address?

and what is开发者_运维百科 the Address format need to be mentioned?


To find latitude and longitude from address string .....

  1. Make object of Geocoder

  2. Call getFromLocationName() pass the address (place name) string as argument also maximum number of results you want for that place name

Here is demo ...

       Geocoder coder = new Geocoder(LocationMap.this);

       List<Address> geocodeResults = coder.getFromLocationName(placeName, 10);

       Iterator<Address> locations = geocodeResults.iterator();

       while (locations.hasNext()) {

           Address loc = locations.next();

           _lattitude_ = loc.getLatitude() ;
           _longidude_ = loc.getLongitude();

       }

And there are no specific address format required.

For example you can try any city name, country name, hotel name, area name, road name, well known place name ( Try "Eiffel tower") ... anything (from many things).


Found this older post. Should solve your problem.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜