currently viewed country in google maps
I need a way to figure out what country (if any) the user is currently viewing on the map. If multiple countries are view'd just return "". I've been working on this for a while, and know how to use the reverse g开发者_C百科eocoder, however, that is not an option as it would be far to many requests.
My best bet is to use some boxes around the countries, and then check if the map center is in any of them.
So in short:
i need a list of countries and there corners cordinates.
i need a way to loop through to find out which one is viewed
Well I am not sure why you can't just get the map center and then reverse geocode that for the country underneath it. Such as:
Even though Canada is in the top part of this map, the center is in the United States.
If you want to check for multiple countries, what I did was create a grid pattern that looks at 9 (or 4 or 16 or whatever you want) evenly distributed points on the map and looks at the countries under each point. I've noticed that sometimes the reverse geocoder returns null even within a county, usually when the marker falls on an uninhabitated region.
If you would like code examples for either of these I will include them.
精彩评论