0
如何確定用戶創建的單張形狀(多邊形|矩形等)內的哪個國家,州,地區,城市或地點?如何確定哪個國家/州/地區/城市/地區位於小冊子多邊形內部|矩形|圓等
如何確定用戶創建的單張形狀(多邊形|矩形等)內的哪個國家,州,地區,城市或地點?如何確定哪個國家/州/地區/城市/地區位於小冊子多邊形內部|矩形|圓等
我認爲您正在尋找反向地理編碼。傳單不提供地理編碼服務,但您可以找到類似的示例here.
Google地理編碼服務會以JSON格式提供結果,但您可能需要支付額外的配額。
樣本鏈接: http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452
與堆棧片段更新時間:
window.cb = function cb(json) {
document.getElementById('result').innerHTML = 'Country:' + json.address.country + '|' + 'State:' + json.address.state + '|' + 'County:' + json.address.county + '|' + 'City:' + json.address.city;
}
window.getLocation = function getLocation() {
var s = document.createElement('script');
s.src = 'http://nominatim.openstreetmap.org/reverse?json_callback=cb&format=json&lat=40.714224&lon=-73.961452&zoom=27&addressdetails=1';
document.getElementsByTagName('head')[0].appendChild(s);
};
.myText {font-weight:bold;font-size:1.0em;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button onclick="getLocation();" name="search" class='myText'>Get Location!</button>
<p id="result" class='myText'></p>
我使用nominatim與反向地理編碼傳單,但它不提供任何這樣的功能。 – codejunkie
它提供了,請參閱此[文檔](http://wiki.openstreetmap.org/wiki/Nominatim#Reverse_Geocoding)。例如:http:?//nominatim.openstreetmap.org/reverse格式= XML&LAT = 52.5487429714954&LON = -1.81602098644987&變焦= 18&addressdetails = 1 –