admin管理员组文章数量:1405141
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 badges3 Answers
Reset to default 4Google 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)
本文标签: phpget city state from google mapStack Overflow
版权声明:本文标题:php - get city state from google map - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744889403a2630680.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论