php - get city state from google map - Stack Overflow

I'm using google map api for showing location. In that i case i need option to get city sate zip f

I'm using google map api for showing location. In that i case i need option to get city sate zip from google map marker. In map , user can move the marker to position it after drag finished it will return the city, state and zip. I have successfully get the lat and lng but how can i get the city , state and zip. please help me as soon as possible..

I'm using google map api for showing location. In that i case i need option to get city sate zip from google map marker. In map , user can move the marker to position it after drag finished it will return the city, state and zip. I have successfully get the lat and lng but how can i get the city , state and zip. please help me as soon as possible..

Share Improve this question edited Jul 17, 2009 at 7:01 RedBlueThing 42.5k17 gold badges98 silver badges122 bronze badges asked Jul 8, 2009 at 15:24 apueeeapueee 1162 silver badges11 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

Google Maps API uses a rather verbose format to extract specific address data:

geocoder.getLocations(latlng, showAddress);

function showAddress(response){
    if (response && response.Status.code == 200){
        var place = reponse.Placemark[0]
        var city  = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName;
        var state = place.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName;
        var zip   = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber;
    }
}

Not too sure about Javascript way, but I have done the same using GWT Google Maps library like this

geocoder.getLocations(<<Your Address>>, new LocationCallback() {
    public void onFailure(int statusCode) {
       Info.show("Failed","Unable to geocode that address.","");
    }

    public void onSuccess(JsArray<Placemark> locations) {
       final Placemark place = locations.get(0);
       Window.alert(place.getCity() + place.getState() + place.getCountry() + place.getPostalCode());
    } });

http://code.google./apis/maps/documentation/services.html#ReverseGeocoding

geocoder = new GClientGeocoder();
...
geocoder.getLocations(latlng, showAddress);

(showAddress is a function)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744889403a4599312.html

相关推荐

  • php - get city state from google map - Stack Overflow

    I'm using google map api for showing location. In that i case i need option to get city sate zip f

    1天前
    60

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信