How to get the current country of the view area?

你离开我真会死。 提交于 2020-01-07 05:27:05

问题


Following part of code delivers me the country where my marker (not draggable) is set …

for (var i = 0; i < results[0].address_components.length; i++) {
  if (results[0].address_components[i].types[0] == "country") {
     clientPositionMarkerCountry = results[0].address_components[i].long_name;
  }
}

When the user moves over an other country (e.g. next to this country or any other) I want to get the current country (or maybe if possible current countries) of the viewarea he is then.


回答1:


Are you looking for something like this:

http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmltest_linktoB.html?lat=43.797409&lng=27.904508&zoom=6&type=m&filename=http://www.geocodezip.com/geoxml3_test/world_countries_kml.xml

Uses geoxml3 to render a KML file. Detects the country polygons that are visible in the viewport and displays them in the sidebar.



来源:https://stackoverflow.com/questions/16065235/how-to-get-the-current-country-of-the-view-area

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!